From 1efaf813e90b04499dde72924122173956a8c937 Mon Sep 17 00:00:00 2001 From: Peter Matula Date: Sun, 14 Jun 2020 19:47:38 +0200 Subject: [PATCH 1/4] bin2llvmir: reduce usage of static data --- .../analyses/reaching_definitions.h | 3 +-- .../bin2llvmir/analyses/symbolic_tree.h | 1 + .../param_return/collector/collector.h | 3 ++- .../register_localization.h | 1 - .../optimizations/simple_types/simple_types.h | 5 ++--- .../calling_convention/calling_convention.h | 1 + .../analyses/reaching_definitions.cpp | 8 +++----- src/bin2llvmir/analyses/symbolic_tree.cpp | 8 ++++++++ src/bin2llvmir/optimizations/decoder/arm.cpp | 2 +- .../optimizations/decoder/arm64.cpp | 2 +- .../optimizations/decoder/decoder_ranges.cpp | 2 +- .../optimizations/decoder/jump_targets.cpp | 2 +- src/bin2llvmir/optimizations/decoder/mips.cpp | 2 +- .../optimizations/decoder/powerpc.cpp | 2 +- src/bin2llvmir/optimizations/decoder/x86.cpp | 2 +- .../inst_opt_rda/inst_opt_rda.cpp | 2 +- .../param_return/collector/collector.cpp | 19 ++++++++++--------- .../provider_init/provider_init.cpp | 17 ++++++++++------- .../register_localization.cpp | 2 -- .../simple_types/simple_types.cpp | 15 ++++++++------- .../types_propagator/types_propagator.cpp | 2 +- .../value_protect/value_protect.cpp | 5 +++++ .../optimizations/writer_dsm/writer_dsm.cpp | 2 +- .../calling_convention/calling_convention.cpp | 6 ++++++ src/bin2llvmir/providers/fileimage.cpp | 2 +- src/bin2llvmir/utils/debug.cpp | 4 ++-- tests/bin2llvmir/utils/llvmir_tests.h | 6 +++++- 27 files changed, 75 insertions(+), 51 deletions(-) diff --git a/include/retdec/bin2llvmir/analyses/reaching_definitions.h b/include/retdec/bin2llvmir/analyses/reaching_definitions.h index 299b4d258..3cdcda5d2 100644 --- a/include/retdec/bin2llvmir/analyses/reaching_definitions.h +++ b/include/retdec/bin2llvmir/analyses/reaching_definitions.h @@ -83,7 +83,7 @@ class Use class BasicBlockEntry { public: - BasicBlockEntry(const llvm::BasicBlock* b = nullptr); + BasicBlockEntry(const llvm::BasicBlock* b = nullptr, std::size_t _id = 0); std::string getName() const; friend std::ostream& operator<<( @@ -115,7 +115,6 @@ class BasicBlockEntry private: unsigned id; - static int newUID; }; class ReachingDefinitionsAnalysis diff --git a/include/retdec/bin2llvmir/analyses/symbolic_tree.h b/include/retdec/bin2llvmir/analyses/symbolic_tree.h index 9f961b178..d8cd6969b 100644 --- a/include/retdec/bin2llvmir/analyses/symbolic_tree.h +++ b/include/retdec/bin2llvmir/analyses/symbolic_tree.h @@ -135,6 +135,7 @@ class SymbolicTree // Global SymbolicTree configuration methods and data. // public: + static void clear(); static bool isVal2ValMapUsed(); static void setAbi(Abi* abi); static void setConfig(Config* config); diff --git a/include/retdec/bin2llvmir/optimizations/param_return/collector/collector.h b/include/retdec/bin2llvmir/optimizations/param_return/collector/collector.h index 21dc046ab..45fdc8ead 100644 --- a/include/retdec/bin2llvmir/optimizations/param_return/collector/collector.h +++ b/include/retdec/bin2llvmir/optimizations/param_return/collector/collector.h @@ -78,7 +78,8 @@ class Collector bool extractFormatString(CallEntry* ce) const; bool storesString(llvm::StoreInst* si, std::string& str) const; - llvm::Value* getRoot(llvm::Value* i, bool first = true) const; + llvm::Value* getRoot(llvm::Value* i) const; + llvm::Value* _getRoot(llvm::Value* i, std::set& seen) const; protected: const Abi* _abi; diff --git a/include/retdec/bin2llvmir/optimizations/register_localization/register_localization.h b/include/retdec/bin2llvmir/optimizations/register_localization/register_localization.h index 8782101df..6f8feb995 100644 --- a/include/retdec/bin2llvmir/optimizations/register_localization/register_localization.h +++ b/include/retdec/bin2llvmir/optimizations/register_localization/register_localization.h @@ -40,7 +40,6 @@ class RegisterLocalization : public llvm::ModulePass llvm::Module* _module = nullptr; Abi* _abi = nullptr; Config* _config = nullptr; - static std::map _type2fnc; }; } // namespace bin2llvmir diff --git a/include/retdec/bin2llvmir/optimizations/simple_types/simple_types.h b/include/retdec/bin2llvmir/optimizations/simple_types/simple_types.h index c0b45e34e..92bfd775e 100644 --- a/include/retdec/bin2llvmir/optimizations/simple_types/simple_types.h +++ b/include/retdec/bin2llvmir/optimizations/simple_types/simple_types.h @@ -132,7 +132,7 @@ using EquationEntrySet = std::unordered_set; class EqSet { public: - EqSet(); + EqSet(std::size_t id); void insert(Config* config, llvm::Value* v, eSourcePriority p = eSourcePriority::PRIORITY_NONE); void insert(llvm::Type* t, eSourcePriority p = eSourcePriority::PRIORITY_NONE); void propagate(llvm::Module* module); @@ -157,8 +157,7 @@ class EqSet public: /// Each instance gets its own unique ID for debug print purposes. - static unsigned newUID; - const unsigned id; + const std::size_t id; /// Type of an entire equivalence set. TypeEntry masterType; diff --git a/include/retdec/bin2llvmir/providers/calling_convention/calling_convention.h b/include/retdec/bin2llvmir/providers/calling_convention/calling_convention.h index b34d3e574..476d3eaf6 100644 --- a/include/retdec/bin2llvmir/providers/calling_convention/calling_convention.h +++ b/include/retdec/bin2llvmir/providers/calling_convention/calling_convention.h @@ -129,6 +129,7 @@ class CallingConventionProvider // Destructor, singleton method. public: static CallingConventionProvider* getProvider(); + static void clear(); // Factory methods. public: diff --git a/src/bin2llvmir/analyses/reaching_definitions.cpp b/src/bin2llvmir/analyses/reaching_definitions.cpp index a6fab4381..a3c3c8ba4 100644 --- a/src/bin2llvmir/analyses/reaching_definitions.cpp +++ b/src/bin2llvmir/analyses/reaching_definitions.cpp @@ -94,7 +94,7 @@ void ReachingDefinitionsAnalysis::initializeBasicBlocks(llvm::Function& F) { for (BasicBlock& B : F) { - BasicBlockEntry bbe(&B); + BasicBlockEntry bbe(&B, bbMap.size()); int insnPos = -1; for (Instruction& I : B) @@ -385,11 +385,9 @@ std::ostream& operator<<(std::ostream& out, const ReachingDefinitionsAnalysis& r //============================================================================= // -int BasicBlockEntry::newUID = 0; - -BasicBlockEntry::BasicBlockEntry(const llvm::BasicBlock* b) : +BasicBlockEntry::BasicBlockEntry(const llvm::BasicBlock* b, std::size_t _id) : bb(b), - id(newUID++) + id(_id) { } diff --git a/src/bin2llvmir/analyses/symbolic_tree.cpp b/src/bin2llvmir/analyses/symbolic_tree.cpp index fd1ce2d82..9207ad256 100644 --- a/src/bin2llvmir/analyses/symbolic_tree.cpp +++ b/src/bin2llvmir/analyses/symbolic_tree.cpp @@ -709,8 +709,16 @@ bool SymbolicTree::_trackOnlyFlagRegisters = false; bool SymbolicTree::_simplifyAtCreation = true; unsigned SymbolicTree::_naryLimit = 3; +void SymbolicTree::clear() +{ + _abi = nullptr; + _config = nullptr; + setToDefaultConfiguration(); +} + void SymbolicTree::setToDefaultConfiguration() { + _val2valUsed = false; _trackThroughAllocaLoads = true; _trackThroughGeneralRegisterLoads = true; _trackOnlyFlagRegisters = false; diff --git a/src/bin2llvmir/optimizations/decoder/arm.cpp b/src/bin2llvmir/optimizations/decoder/arm.cpp index e7cd9d894..148793cc3 100644 --- a/src/bin2llvmir/optimizations/decoder/arm.cpp +++ b/src/bin2llvmir/optimizations/decoder/arm.cpp @@ -109,7 +109,7 @@ std::size_t Decoder::decodeJumpTargetDryRun_arm( auto basicMode = _c2l->getBasicMode(); if (mode != basicMode) _c2l->modifyBasicMode(mode); - static csh ce = _c2l->getCapstoneEngine(); + csh ce = _c2l->getCapstoneEngine(); decodedSz = 0; uint64_t addr = jt.getAddress(); diff --git a/src/bin2llvmir/optimizations/decoder/arm64.cpp b/src/bin2llvmir/optimizations/decoder/arm64.cpp index ca90503f2..2ecb9b875 100644 --- a/src/bin2llvmir/optimizations/decoder/arm64.cpp +++ b/src/bin2llvmir/optimizations/decoder/arm64.cpp @@ -55,7 +55,7 @@ std::size_t Decoder::decodeJumpTargetDryRun_arm64( return true; } - static csh ce = _c2l->getCapstoneEngine(); + csh ce = _c2l->getCapstoneEngine(); uint64_t addr = jt.getAddress(); std::size_t nops = 0; diff --git a/src/bin2llvmir/optimizations/decoder/decoder_ranges.cpp b/src/bin2llvmir/optimizations/decoder/decoder_ranges.cpp index 981fb97d3..6a9c64072 100644 --- a/src/bin2llvmir/optimizations/decoder/decoder_ranges.cpp +++ b/src/bin2llvmir/optimizations/decoder/decoder_ranges.cpp @@ -78,7 +78,7 @@ void RangesToDecode::removeZeroSequences( FileImage* image, common::AddressRangeContainer& rs) { - static unsigned minSequence = 0x50; // TODO: Maybe should be smaller. + unsigned minSequence = 0x50; // TODO: Maybe should be smaller. retdec::common::AddressRangeContainer toRemove; for (auto& range : rs) diff --git a/src/bin2llvmir/optimizations/decoder/jump_targets.cpp b/src/bin2llvmir/optimizations/decoder/jump_targets.cpp index 54cb93f3a..23b6c85b4 100644 --- a/src/bin2llvmir/optimizations/decoder/jump_targets.cpp +++ b/src/bin2llvmir/optimizations/decoder/jump_targets.cpp @@ -187,7 +187,7 @@ const JumpTarget* JumpTargets::push( retdec::common::Address f, std::optional sz) { - static auto& arch = config->getConfig().architecture; + auto& arch = config->getConfig().architecture; if (arch.isArm64() && m == CS_MODE_THUMB) { diff --git a/src/bin2llvmir/optimizations/decoder/mips.cpp b/src/bin2llvmir/optimizations/decoder/mips.cpp index cae7bd2a8..12af39d2f 100644 --- a/src/bin2llvmir/optimizations/decoder/mips.cpp +++ b/src/bin2llvmir/optimizations/decoder/mips.cpp @@ -75,7 +75,7 @@ std::size_t Decoder::decodeJumpTargetDryRun_mips( return true; } - static csh ce = _c2l->getCapstoneEngine(); + csh ce = _c2l->getCapstoneEngine(); uint64_t addr = jt.getAddress(); std::size_t nops = 0; diff --git a/src/bin2llvmir/optimizations/decoder/powerpc.cpp b/src/bin2llvmir/optimizations/decoder/powerpc.cpp index fbe90c382..b4f3bb309 100644 --- a/src/bin2llvmir/optimizations/decoder/powerpc.cpp +++ b/src/bin2llvmir/optimizations/decoder/powerpc.cpp @@ -25,7 +25,7 @@ std::size_t Decoder::decodeJumpTargetDryRun_ppc( return true; } - static csh ce = _c2l->getCapstoneEngine(); + csh ce = _c2l->getCapstoneEngine(); uint64_t addr = jt.getAddress(); std::size_t nops = 0; diff --git a/src/bin2llvmir/optimizations/decoder/x86.cpp b/src/bin2llvmir/optimizations/decoder/x86.cpp index 8b39e4bbf..0aefa9dd5 100644 --- a/src/bin2llvmir/optimizations/decoder/x86.cpp +++ b/src/bin2llvmir/optimizations/decoder/x86.cpp @@ -25,7 +25,7 @@ std::size_t Decoder::decodeJumpTargetDryRun_x86( return true; } - static csh ce = _c2l->getCapstoneEngine(); + csh ce = _c2l->getCapstoneEngine(); uint64_t addr = jt.getAddress(); std::size_t nops = 0; diff --git a/src/bin2llvmir/optimizations/inst_opt_rda/inst_opt_rda.cpp b/src/bin2llvmir/optimizations/inst_opt_rda/inst_opt_rda.cpp index 99c0a5770..7d8efac8d 100644 --- a/src/bin2llvmir/optimizations/inst_opt_rda/inst_opt_rda.cpp +++ b/src/bin2llvmir/optimizations/inst_opt_rda/inst_opt_rda.cpp @@ -29,7 +29,7 @@ namespace inst_opt_rda { */ bool unusedStores(llvm::Instruction* insn, ReachingDefinitionsAnalysis& RDA) { - static auto* abi = AbiProvider::getAbi(insn->getModule()); + auto* abi = AbiProvider::getAbi(insn->getModule()); auto* store = llvm::dyn_cast(insn); if (store == nullptr || (llvm::isa(store->getPointerOperand()) diff --git a/src/bin2llvmir/optimizations/param_return/collector/collector.cpp b/src/bin2llvmir/optimizations/param_return/collector/collector.cpp index 42c546044..f110bb765 100644 --- a/src/bin2llvmir/optimizations/param_return/collector/collector.cpp +++ b/src/bin2llvmir/optimizations/param_return/collector/collector.cpp @@ -545,13 +545,14 @@ bool Collector::storesString(StoreInst* si, std::string& str) const return true; } -llvm::Value* Collector::getRoot(llvm::Value* i, bool first) const +llvm::Value* Collector::getRoot(llvm::Value* i) const +{ + std::set seen; + _getRoot(i, seen); +} + +llvm::Value* Collector::_getRoot(llvm::Value* i, std::set& seen) const { - static std::set seen; - if (first) - { - seen.clear(); - } if (seen.count(i)) { return i; @@ -568,7 +569,7 @@ llvm::Value* Collector::getRoot(llvm::Value* i, bool first) const auto* d = (*u->defs.begin())->def; if (auto* s = dyn_cast(d)) { - return getRoot(s->getValueOperand(), false); + return _getRoot(s->getValueOperand(), seen); } else { @@ -577,7 +578,7 @@ llvm::Value* Collector::getRoot(llvm::Value* i, bool first) const } else if (auto* l = dyn_cast(ii)) { - return getRoot(l->getPointerOperand(), false); + return _getRoot(l->getPointerOperand(), seen); } else { @@ -586,7 +587,7 @@ llvm::Value* Collector::getRoot(llvm::Value* i, bool first) const } else if (auto* l = dyn_cast(ii)) { - return getRoot(l->getPointerOperand(), false); + return _getRoot(l->getPointerOperand(), seen); } else { diff --git a/src/bin2llvmir/optimizations/provider_init/provider_init.cpp b/src/bin2llvmir/optimizations/provider_init/provider_init.cpp index b84dde1a3..8d107d231 100644 --- a/src/bin2llvmir/optimizations/provider_init/provider_init.cpp +++ b/src/bin2llvmir/optimizations/provider_init/provider_init.cpp @@ -170,11 +170,16 @@ void ProviderInitialization::setConfig(retdec::config::Config* c) */ bool ProviderInitialization::runOnModule(Module& m) { - static bool firstRun = true; - if (!firstRun) - { - return false; - } + AbiProvider::clear(); + AsmInstruction::clear(); + ConfigProvider::clear(); + DebugFormatProvider::clear(); + DemanglerProvider::clear(); + FileImageProvider::clear(); + LtiProvider::clear(); + NamesProvider::clear(); + SymbolicTree::clear(); + CallingConventionProvider::clear(); // Config. // @@ -397,8 +402,6 @@ bool ProviderInitialization::runOnModule(Module& m) AsmInstruction::clear(); - firstRun = false; - return false; } diff --git a/src/bin2llvmir/optimizations/register_localization/register_localization.cpp b/src/bin2llvmir/optimizations/register_localization/register_localization.cpp index 21adac643..a183d2731 100644 --- a/src/bin2llvmir/optimizations/register_localization/register_localization.cpp +++ b/src/bin2llvmir/optimizations/register_localization/register_localization.cpp @@ -24,8 +24,6 @@ namespace bin2llvmir { char RegisterLocalization::ID = 0; -std::map RegisterLocalization::_type2fnc; - static RegisterPass X( "retdec-register-localization", "Make all registers local", diff --git a/src/bin2llvmir/optimizations/simple_types/simple_types.cpp b/src/bin2llvmir/optimizations/simple_types/simple_types.cpp index d2557fe27..80bd72fc8 100644 --- a/src/bin2llvmir/optimizations/simple_types/simple_types.cpp +++ b/src/bin2llvmir/optimizations/simple_types/simple_types.cpp @@ -87,6 +87,8 @@ bool SimpleTypesAnalysis::runOnModule(Module& M) if (first) { + first = false; + RDA.runOnModule(M, AbiProvider::getAbi(&M)); buildEqSets(M); buildEquations(); @@ -94,11 +96,12 @@ bool SimpleTypesAnalysis::runOnModule(Module& M) eqSets.apply(module, config, objf, instToErase); eraseObsoleteInstructions(); setGlobalConstants(); - first = false; RDA.clear(); } else { + first = true; + instToErase.clear(); IrModifier irModif(module, config); @@ -721,7 +724,7 @@ void SimpleTypesAnalysis::eraseObsoleteInstructions() EqSet& EqSetContainer::createEmptySet() { - eqSets.push_back( EqSet() ); + eqSets.push_back(EqSet(eqSets.size())); return eqSets.back(); } @@ -762,10 +765,8 @@ std::ostream& operator<<(std::ostream& out, const EqSetContainer& eqs) //============================================================================= // -unsigned EqSet::newUID = 0; - -EqSet::EqSet() : - id(newUID++) +EqSet::EqSet(std::size_t id) : + id(id) { } @@ -1228,7 +1229,7 @@ void EqSet::apply( LOG << "\napply BEGIN " << id << " =============================\n"; - static auto &conf = config->getConfig(); + auto &conf = config->getConfig(); IrModifier irModif(module, config); for (auto& vs : valSet) diff --git a/src/bin2llvmir/optimizations/types_propagator/types_propagator.cpp b/src/bin2llvmir/optimizations/types_propagator/types_propagator.cpp index 70ba34744..dff20fdb7 100644 --- a/src/bin2llvmir/optimizations/types_propagator/types_propagator.cpp +++ b/src/bin2llvmir/optimizations/types_propagator/types_propagator.cpp @@ -97,7 +97,7 @@ if (fnc.getName() != "_func") continue; bool TypesPropagator::skipRootProcessing(llvm::Value* val) { - static auto* special = AsmInstruction::getLlvmToAsmGlobalVariable(_module); + auto* special = AsmInstruction::getLlvmToAsmGlobalVariable(_module); return val == special || _abi->isRegister(val) // || (llvm::isa(val) diff --git a/src/bin2llvmir/optimizations/value_protect/value_protect.cpp b/src/bin2llvmir/optimizations/value_protect/value_protect.cpp index 8674f8a62..edf2fe8c5 100644 --- a/src/bin2llvmir/optimizations/value_protect/value_protect.cpp +++ b/src/bin2llvmir/optimizations/value_protect/value_protect.cpp @@ -303,6 +303,11 @@ bool ValueProtect::run() bool changed = false; + if (!_type2fnc.empty() && _type2fnc.begin()->second->getParent() != _module) + { + _type2fnc.clear(); + } + changed = _type2fnc.empty() ? protect() : unprotect(); return changed; diff --git a/src/bin2llvmir/optimizations/writer_dsm/writer_dsm.cpp b/src/bin2llvmir/optimizations/writer_dsm/writer_dsm.cpp index d6ab658bd..c040c8744 100644 --- a/src/bin2llvmir/optimizations/writer_dsm/writer_dsm.cpp +++ b/src/bin2llvmir/optimizations/writer_dsm/writer_dsm.cpp @@ -259,7 +259,7 @@ void DsmWriter::generateFunction( void DsmWriter::getAsmInstructionHex(AsmInstruction& ai, std::ostream& ret) { - static std::size_t longestHexa = _longestInst * 3 - 1; + std::size_t longestHexa = _longestInst * 3 - 1; const std::size_t aiHexa = ai.getByteSize() * 3 - 1; std::vector bytes; diff --git a/src/bin2llvmir/providers/calling_convention/calling_convention.cpp b/src/bin2llvmir/providers/calling_convention/calling_convention.cpp index b6cae100f..3c47b0147 100644 --- a/src/bin2llvmir/providers/calling_convention/calling_convention.cpp +++ b/src/bin2llvmir/providers/calling_convention/calling_convention.cpp @@ -192,6 +192,12 @@ CallingConventionProvider* CallingConventionProvider::getProvider() return &instance; } +void CallingConventionProvider::clear() +{ + auto* ccp = getProvider(); + ccp->_id2cc.clear(); +} + void CallingConventionProvider::registerCC( const CallingConvention::ID& cc, const CallingConvention::ConstructorMethod& con) diff --git a/src/bin2llvmir/providers/fileimage.cpp b/src/bin2llvmir/providers/fileimage.cpp index e3b40450c..84d308a23 100644 --- a/src/bin2llvmir/providers/fileimage.cpp +++ b/src/bin2llvmir/providers/fileimage.cpp @@ -507,7 +507,7 @@ llvm::Constant* FileImage::getConstant( refGvs.push_back(newGv); addr += Abi::getTypeByteSize(_module, Abi::getDefaultType(_module)); - static auto& conf = config->getConfig(); + auto& conf = config->getConfig(); if (conf.globals.getObjectByAddress(addr)) { break; diff --git a/src/bin2llvmir/utils/debug.cpp b/src/bin2llvmir/utils/debug.cpp index 3c901a275..643f0b7f2 100644 --- a/src/bin2llvmir/utils/debug.cpp +++ b/src/bin2llvmir/utils/debug.cpp @@ -97,7 +97,7 @@ void dumpControFlowToJsonBasicBlock( llvm::BasicBlock& bbEnd, std::ostream &out) { - static auto* config = ConfigProvider::getConfig(bb.getModule()); + auto* config = ConfigProvider::getConfig(bb.getModule()); auto start = AsmInstruction::getTrueBasicBlockAddress(&bb); auto end = AsmInstruction::getBasicBlockEndAddress(&bbEnd); @@ -212,7 +212,7 @@ void dumpControFlowToJsonFunction( llvm::Function& f, std::ostream &out) { - static auto* config = ConfigProvider::getConfig(f.getParent()); + auto* config = ConfigProvider::getConfig(f.getParent()); auto start = AsmInstruction::getFunctionAddress(&f); auto end = AsmInstruction::getFunctionEndAddress(&f); diff --git a/tests/bin2llvmir/utils/llvmir_tests.h b/tests/bin2llvmir/utils/llvmir_tests.h index 535f6d770..c39d7de3c 100644 --- a/tests/bin2llvmir/utils/llvmir_tests.h +++ b/tests/bin2llvmir/utils/llvmir_tests.h @@ -29,6 +29,7 @@ #include "retdec/bin2llvmir/providers/demangler.h" #include "retdec/bin2llvmir/providers/fileimage.h" #include "retdec/bin2llvmir/providers/lti.h" +#include "retdec/bin2llvmir/providers/names.h" #include "retdec/bin2llvmir/utils/debug.h" #include "retdec/utils/string.h" @@ -56,12 +57,15 @@ class LlvmIrTests : public ::testing::Test void clearAllStaticData() { AbiProvider::clear(); + AsmInstruction::clear(); ConfigProvider::clear(); DebugFormatProvider::clear(); DemanglerProvider::clear(); FileImageProvider::clear(); - AsmInstruction::clear(); LtiProvider::clear(); + NamesProvider::clear(); + SymbolicTree::clear(); + CallingConventionProvider::clear(); } /** From 7de4a15878c703e29844655416a3290ca04f00ca Mon Sep 17 00:00:00 2001 From: Peter Matula Date: Sun, 14 Jun 2020 20:00:09 +0200 Subject: [PATCH 2/4] bin2llvmir/cc: do not clean --- .../providers/calling_convention/calling_convention.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bin2llvmir/providers/calling_convention/calling_convention.cpp b/src/bin2llvmir/providers/calling_convention/calling_convention.cpp index 3c47b0147..e76e7747e 100644 --- a/src/bin2llvmir/providers/calling_convention/calling_convention.cpp +++ b/src/bin2llvmir/providers/calling_convention/calling_convention.cpp @@ -194,8 +194,9 @@ CallingConventionProvider* CallingConventionProvider::getProvider() void CallingConventionProvider::clear() { - auto* ccp = getProvider(); - ccp->_id2cc.clear(); + // TODO: probably not needed. and definitely not working. +// auto* ccp = getProvider(); +// ccp->_id2cc.clear(); } void CallingConventionProvider::registerCC( From e29a62abae4217db49a7e9b36d883e55f0d4d0a8 Mon Sep 17 00:00:00 2001 From: Peter Matula Date: Sun, 14 Jun 2020 21:15:57 +0200 Subject: [PATCH 3/4] bin2llvmir: fix param return collector --- .../optimizations/param_return/collector/collector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin2llvmir/optimizations/param_return/collector/collector.cpp b/src/bin2llvmir/optimizations/param_return/collector/collector.cpp index f110bb765..07ba95e76 100644 --- a/src/bin2llvmir/optimizations/param_return/collector/collector.cpp +++ b/src/bin2llvmir/optimizations/param_return/collector/collector.cpp @@ -548,7 +548,7 @@ bool Collector::storesString(StoreInst* si, std::string& str) const llvm::Value* Collector::getRoot(llvm::Value* i) const { std::set seen; - _getRoot(i, seen); + return _getRoot(i, seen); } llvm::Value* Collector::_getRoot(llvm::Value* i, std::set& seen) const From a395885877dec8638dd8a3720dff52d8a7ea9df7 Mon Sep 17 00:00:00 2001 From: Peter Matula Date: Mon, 15 Jun 2020 06:32:47 +0200 Subject: [PATCH 4/4] add missing includes --- src/bin2llvmir/optimizations/provider_init/provider_init.cpp | 1 + tests/bin2llvmir/utils/llvmir_tests.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/bin2llvmir/optimizations/provider_init/provider_init.cpp b/src/bin2llvmir/optimizations/provider_init/provider_init.cpp index 8d107d231..922359f83 100644 --- a/src/bin2llvmir/optimizations/provider_init/provider_init.cpp +++ b/src/bin2llvmir/optimizations/provider_init/provider_init.cpp @@ -13,6 +13,7 @@ #include "retdec/bin2llvmir/optimizations/provider_init/provider_init.h" #include "retdec/bin2llvmir/providers/abi/abi.h" #include "retdec/bin2llvmir/providers/asm_instruction.h" +#include "retdec/bin2llvmir/providers/calling_convention/calling_convention.h" #include "retdec/bin2llvmir/providers/config.h" #include "retdec/bin2llvmir/providers/debugformat.h" #include "retdec/bin2llvmir/providers/demangler.h" diff --git a/tests/bin2llvmir/utils/llvmir_tests.h b/tests/bin2llvmir/utils/llvmir_tests.h index c39d7de3c..5e471a62b 100644 --- a/tests/bin2llvmir/utils/llvmir_tests.h +++ b/tests/bin2llvmir/utils/llvmir_tests.h @@ -20,10 +20,13 @@ #include #include +#include "retdec/bin2llvmir/analyses/symbolic_tree.h" #include "retdec/bin2llvmir/utils/llvm.h" #include "retdec/fileformat/file_format/raw_data/raw_data_format.h" #include "retdec/loader/loader.h" +#include "retdec/bin2llvmir/providers/abi/abi.h" #include "retdec/bin2llvmir/providers/asm_instruction.h" +#include "retdec/bin2llvmir/providers/calling_convention/calling_convention.h" #include "retdec/bin2llvmir/providers/config.h" #include "retdec/bin2llvmir/providers/debugformat.h" #include "retdec/bin2llvmir/providers/demangler.h"