MCPcopy Create free account
hub / github.com/avast/retdec / handleInstruction

Method handleInstruction

src/bin2llvmir/optimizations/stack/stack.cpp:131–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131void StackAnalysis::handleInstruction(
132 ReachingDefinitionsAnalysis& RDA,
133 llvm::Instruction* inst,
134 llvm::Value* val,
135 llvm::Type* type,
136 std::map<llvm::Value*, llvm::Value*>& val2val)
137{
138 LOG << llvmObjToString(inst) << std::endl;
139
140 auto root = SymbolicTree::PrecomputedRdaWithValueMap(RDA, val, &val2val);
141 LOG << root << std::endl;
142
143 if (!root.isVal2ValMapUsed())
144 {
145 bool stackPtr = false;
146 for (SymbolicTree* n : root.getPostOrder())
147 {
148 if (_abi->isStackPointerRegister(n->value))
149 {
150 stackPtr = true;
151 break;
152 }
153 }
154 if (!stackPtr)
155 {
156 LOG << "===> no SP" << std::endl;
157 return;
158 }
159 }
160
161 auto* debugSv = getDebugStackVariable(inst->getFunction(), root);
162 auto* configSv = getConfigStackVariable(inst->getFunction(), root);
163
164 root.simplifyNode();
165 LOG << root << std::endl;
166
167 if (debugSv == nullptr)
168 {
169 debugSv = getDebugStackVariable(inst->getFunction(), root);
170 }
171
172 if (configSv == nullptr)
173 {
174 configSv = getConfigStackVariable(inst->getFunction(), root);
175 }
176
177 auto* ci = dyn_cast_or_null<ConstantInt>(root.value);
178 if (ci == nullptr)
179 {
180 return;
181 }
182
183 if (auto* s = dyn_cast<StoreInst>(inst))
184 {
185 if (s->getValueOperand() == val)
186 {
187 val2val[inst] = ci;
188 }

Callers

nothing calls this directly

Calls 13

stringToLlvmTypeDefaultFunction · 0.85
isVal2ValMapUsedMethod · 0.80
getPostOrderMethod · 0.80
simplifyNodeMethod · 0.80
getLlvmIrMethod · 0.80
getStackVariableMethod · 0.80
llvmObjToStringFunction · 0.50
getFunctionMethod · 0.45
getNameMethod · 0.45
getElementTypeMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected