Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations #731

Merged
merged 29 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
87c6c5e
bin2llvmir: use faster linear symbolic trees in binary decoding phase
PeterMatula Jan 3, 2020
9ac5bb2
bin2llvmir/symbolictree: use the new ctor interface everywhere
PeterMatula Jan 3, 2020
bae7c78
bin2llvmir/symbolyctree: do not record already processed values
PeterMatula Jan 3, 2020
c41d93f
bin2llvmir/symbolictree: unify 2 ctors into 1
PeterMatula Jan 3, 2020
1087b0c
progress
PeterMatula Jan 4, 2020
a76b109
Merge branch 'master' into optimizations
PeterMatula Jan 31, 2020
c25c01d
bin2llvmir/decoder: optmize decoder.
PeterMatula Jan 31, 2020
c30c33e
cmake/options.cmake: fix, add RETDEC_ENABLE_RETDECTOOL option
PeterMatula Jan 31, 2020
e3aba89
bin2llvmir/stack: remove instruction made unused by the analysis
PeterMatula Mar 20, 2020
beb2891
progress
PeterMatula Mar 20, 2020
e92e566
bin2llvmir/fpu: remove operations on fpu top when analysis is done
PeterMatula Mar 21, 2020
8f2c58a
capstone2llvmir/x86: remove all x87 tag reg related operations.
PeterMatula Mar 21, 2020
ccda153
bin2llvmir/cond_br_opt: erase insn unused after the opt
PeterMatula Mar 21, 2020
2330097
bin2llvmir/constants: remove insn unused after opt
PeterMatula Mar 21, 2020
66289f5
bin2llvmir/inst_opt: fix header guard names
PeterMatula Mar 21, 2020
d2452d4
bin2llvmir/rda: add position in BB to defs & uses
PeterMatula Mar 21, 2020
f77d124
bin2llvmir/irmodifier: better implementation of _eraseUnusedInstructi…
PeterMatula Mar 21, 2020
066eb2e
bin2llvmir/rda: collect also ptr2int and gep uses
PeterMatula Mar 22, 2020
b463779
bin2llvmir/value_protect: do not iterate over regs from abi
PeterMatula Mar 22, 2020
9e9ef27
bin2llvmir: add inst_opt_rda pass
PeterMatula Mar 22, 2020
c964c3f
bin2llvmir: fix int covnersions and x86 addr spaces.
PeterMatula Mar 31, 2020
2099369
bin2llvmir: remove unused local_vars analysis
PeterMatula Mar 31, 2020
5c3456f
bin2llvmir/idioms_libgcc: remove reg localization from this pass.
PeterMatula Mar 31, 2020
3254cc0
bin2llvmir/x86_fpu: remove more unused insns
PeterMatula Mar 31, 2020
b69ff63
Merge branch 'master' into optimizations
PeterMatula Apr 6, 2020
cf39921
Merge branch 'master' into stack-remove-unused-insn
PeterMatula Apr 6, 2020
d8119ac
Merge branch 'stack-remove-unused-insn' into optimizations
PeterMatula Apr 6, 2020
5705290
capstone2llvmir: remove unsused variables
PeterMatula Apr 7, 2020
c7dcd74
bin2llvmir: fix doxygen warnings
PeterMatula Apr 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bin2llvmir/x86_fpu: remove more unused insns
  • Loading branch information
PeterMatula committed Mar 31, 2020
commit 3254cc042ddcbed8611848a6ff07e6d5ec2872e0
3 changes: 3 additions & 0 deletions include/retdec/bin2llvmir/optimizations/x87_fpu/x87_fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define RETDEC_BIN2LLVMIR_OPTIMIZATIONS_X87_FPU_X87_FPU_H

#include <map>
#include <unordered_set>

#include <llvm/IR/Module.h>
#include <llvm/Pass.h>
Expand Down Expand Up @@ -44,6 +45,8 @@ class X87FpuAnalysis : public llvm::ModulePass
Config* _config = nullptr;
Abi* _abi = nullptr;
llvm::GlobalVariable* top = nullptr;

std::unordered_set<llvm::Value*> _toRemove;
};

} // namespace bin2llvmir
Expand Down
13 changes: 9 additions & 4 deletions src/bin2llvmir/optimizations/x87_fpu/x87_fpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ bool X87FpuAnalysis::analyzeBb(
LOG << "\t\t\t" << "store -- " << reg->getName().str() << std::endl;

new StoreInst(callStore->getArgOperand(1), reg, callStore);
_toRemove.insert(callStore->getArgOperand(0));
// We need to remove this righ away.
// It does not work if we store it to _toRemove set.
callStore->eraseFromParent();
changed = true;
} else if (callLoad
Expand All @@ -222,6 +225,8 @@ bool X87FpuAnalysis::analyzeBb(
auto *conv = IrModifier::convertValueToType(lTmp, callLoad->getType(), callLoad);

callLoad->replaceAllUsesWith(conv);
// We need to remove this righ away.
// It does not work if we store it to _toRemove set.
callLoad->eraseFromParent();
changed = true;
} else if (callStore || callLoad) {
Expand All @@ -242,21 +247,21 @@ bool X87FpuAnalysis::analyzeBb(

void X87FpuAnalysis::removeAllFpuTopOperations()
{
std::unordered_set<llvm::Value*> toRemove;
// std::unordered_set<llvm::Value*> toRemove;
for (Function& f : *_module)
for (auto it = inst_begin(&f), eIt = inst_end(&f); it != eIt; ++it)
{
Instruction* i = &*it;
if (auto* l = dyn_cast<LoadInst>(i); l && l->getPointerOperand() == top)
{
toRemove.insert(i);
_toRemove.insert(i);
}
if (auto* s = dyn_cast<StoreInst>(i); s && s->getPointerOperand() == top)
{
toRemove.insert(i);
_toRemove.insert(i);
}
}
IrModifier::eraseUnusedInstructionsRecursive(toRemove);
IrModifier::eraseUnusedInstructionsRecursive(_toRemove);
}

} // namespace bin2llvmir
Expand Down