InitModelTypes: detect type for isolated callees

Before this commit initModelTypes wasn't able to detect the type of the
callee operand for calls to isolated functions.
This commit properly supports this case.
This commit is contained in:
Pietro Fezzardi
2023-07-20 17:16:58 +02:00
committed by Alessandro Di Federico
parent e423676da3
commit f04dea7636
+23 -6
View File
@@ -334,12 +334,29 @@ ModelTypesMap initModelTypes(FunctionMetadataCache &Cache,
const auto *InstType = I.getType();
// Visit operands, in case they are constants, globals or constexprs
for (const llvm::Value *Op : I.operand_values()) {
// Ignore operands of some custom opcodes
if (isCallTo(&I, "revng_call_stack_arguments"))
continue;
addOperandType(Op, Model, TypeMap, PointersOnly);
// Ignore operands of some custom opcodes
if (not isCallTo(&I, "revng_call_stack_arguments")) {
// Visit operands, in case they are constants, globals or constexprs
for (const llvm::Use &Op : I.operands()) {
if (auto *Call = getCallToIsolatedFunction(&I);
Call and Call->isCallee(&Op)) {
// Isolated functions have their prototype in the model
//
// If it's a direct call to an isolated function we know the type of
// the function, which affects the type of the
auto *Called = Call->getCalledOperand();
if (auto *CalledFunction = dyn_cast<llvm::Function>(Called)) {
auto Prototype = Cache.getCallSitePrototype(Model, Call);
revng_assert(Prototype.isValid() and not Prototype.empty());
TypeMap.insert({ CalledFunction,
createPointerTo(Prototype, Model) });
continue;
}
}
addOperandType(Op, Model, TypeMap, PointersOnly);
}
}
// Insert void types for consistency