| 129 | } |
| 130 | |
| 131 | void 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 | } |
nothing calls this directly
no test coverage detected