[PATCH] D139861: [llvm] boilerplate for new callbrprepare codegen IR pass
James Y Knight via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 13:57:46 PST 2023
jyknight added inline comments.
================
Comment at: llvm/lib/CodeGen/CallBrPrepare.cpp:9-20
+// This pass lowers callbrs in LLVM IR to something that the backend can
+// perform correct instruction selection for. In particular, callbr may have
+// inline asm with output constraints that require registers. These registers
+// will need to be copied back to virtual registers somewhere. If we have
+// critical edges, we may need to split them. Regardless of critical edges, we
+// create distinct new SSA values for each indirect destination of the callbr,
+// then remap users of the direct destinations value which aren't dominated by
----------------
Suggestion:
This pass lowers callbrs in LLVM IR in order to to assist SelectionDAG's codegen.
In particular, this pass assists in inserting register copies for the output values of a callbr along the edges leading to the indirect target blocks. Though the output SSA value is defined by the callbr instruction itself in the IR representation, the value cannot be copied to the appropriate virtual registers prior to jumping to an indirect label, since the jump occurs within the user-provided assembly blob.
Instead, those copies must occur separately at the beginning of each indirect target. That requires that we create a separate SSA definition in each of them (via llvm.callbr.landingpad), and may require splitting critical edges so we have a location to place the intrinsic. Finally, we remap users of the original callbr output SSA value to instead point to the appropriate llvm.callbr.landingpad value.
Ideally, this could be done inside SelectionDAG, or in the MachineInstruction representation, without the use of an IR-level intrinsic. But, within the current framework, it’s simpler to implement as an IR pass. (If support for callbr in GlobalISel is implemented, it’s worth considering whether this is still required.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139861/new/
https://reviews.llvm.org/D139861
More information about the llvm-commits
mailing list