In LowerCall in X86IselLowering, I am trying to figure out how to (if possible) retrieve the info of the callee, which is just an SDValue at this stage. Is it possible to look up the MachineFunction of the callee to get its attributes? I assume there’s some global context keeping track of all MachineFunctions?
It depends. You can check the Callee
to get the IR Function
, e.g.
if (auto *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
if (auto *F = dyn_cast<Function>(G->getGlobal()) {
// ...
}
}
But this does not always work. E.g. for external functions, the Callee
is of type ExternalSymbolSDNode
, and this is really just the name.
Regards,
Kai
1 Like
This will miss the attributes present on the original call site
The CallLoweringInfo has the CallBase for the callsite, which you can query during the initial DAG construction. Beyond that you can’t reliably find the attributes
Also how do I get MachineInfo of the callee?
What do you mean by MachineInfo? Normally the MachineFunction only exists for the current function, but it’s possible to have module or SCC analyses depend on other functions