retdec
|
Functions | |
bool | optimize (llvm::Instruction *insn) |
bool | addZero (llvm::Instruction *insn) |
bool | subZero (llvm::Instruction *insn) |
bool | truncZext (llvm::Instruction *insn) |
bool | xorXX (llvm::Instruction *insn) |
bool | xorLoadXX (llvm::Instruction *insn) |
bool | orAndXX (llvm::Instruction *insn) |
bool | orAndLoadXX (llvm::Instruction *insn) |
bool | xor_i1 (llvm::Instruction *insn) |
bool | and_i1 (llvm::Instruction *insn) |
bool | addSequence (llvm::Instruction *insn) |
llvm::Value * | castSequence (llvm::CastInst *cast1, llvm::CastInst *cast2) |
llvm::Value * | castSequenceFinder (llvm::Value *insn) |
bool | castSequenceWrapper (llvm::Instruction *insn) |
bool | storeToBitcastPointer (llvm::Instruction *insn) |
bool | loadFromBitcastPointer (llvm::Instruction *insn) |
Variables | |
std::vector< bool(*)(llvm::Instruction *)> | optimizations |
bool retdec::bin2llvmir::inst_opt::addSequence | ( | llvm::Instruction * | insn | ) |
a = add x, c1 b = add a, c2 => b = add x, (c1 + c2)
bool retdec::bin2llvmir::inst_opt::addZero | ( | llvm::Instruction * | insn | ) |
x = add y, 0 => x = y
x = add 0, y => x = y
bool retdec::bin2llvmir::inst_opt::and_i1 | ( | llvm::Instruction * | insn | ) |
a = and i1 x, y => a = icmp eq i1 x, y
llvm::Value* retdec::bin2llvmir::inst_opt::castSequence | ( | llvm::CastInst * | cast1, |
llvm::CastInst * | cast2 | ||
) |
cast1 fp/ptr to ... ... cast2 ... to fp/ptr => cast fp/ptr to fp/ptr
Do not do this for integers. It is not always safe. E.g. i32 -> i1 -> i32 is not the same as i32 -> i32. It may not be safe for pointers and floats as well, but we leave it for now.
llvm::Value* retdec::bin2llvmir::inst_opt::castSequenceFinder | ( | llvm::Value * | insn | ) |
Find cast sequnces to try to optimize.
bool retdec::bin2llvmir::inst_opt::castSequenceWrapper | ( | llvm::Instruction * | insn | ) |
Apply cast optimization repeatedly until it can not be applied anymore.
bool retdec::bin2llvmir::inst_opt::loadFromBitcastPointer | ( | llvm::Instruction * | insn | ) |
bool retdec::bin2llvmir::inst_opt::optimize | ( | llvm::Instruction * | insn | ) |
bool retdec::bin2llvmir::inst_opt::orAndLoadXX | ( | llvm::Instruction * | insn | ) |
a = load x b = load x c = or a, b => c = 0
a = load x b = load x c = and a, b => c = 0
bool retdec::bin2llvmir::inst_opt::orAndXX | ( | llvm::Instruction * | insn | ) |
a = or x, x => a = x
a = and x, x => a = x
bool retdec::bin2llvmir::inst_opt::storeToBitcastPointer | ( | llvm::Instruction * | insn | ) |
This is countering an undesirable LLVM instrcombine optimization that is going the other way.
bool retdec::bin2llvmir::inst_opt::subZero | ( | llvm::Instruction * | insn | ) |
x = sub y, 0 => x = use y
bool retdec::bin2llvmir::inst_opt::truncZext | ( | llvm::Instruction * | insn | ) |
a = trunc i32 val to i8 b = zext i8 a to i32 => b = and i32 val, 255
a = trunc i32 val to i16 b = zext i16 a to i32 => b = and i32 val, 65535
bool retdec::bin2llvmir::inst_opt::xor_i1 | ( | llvm::Instruction * | insn | ) |
a = xor i1 x, y => a = icmp ne i1 x, y
bool retdec::bin2llvmir::inst_opt::xorLoadXX | ( | llvm::Instruction * | insn | ) |
a = load x b = load x c = xor a, b => c = 0
bool retdec::bin2llvmir::inst_opt::xorXX | ( | llvm::Instruction * | insn | ) |
a = xor x, x => a = 0
std::vector<bool (*)(llvm::Instruction*)> retdec::bin2llvmir::inst_opt::optimizations |
Order here is important. More specific patterns must go first, more general later.