[llvm] [X86][GlobalISel] Use GIntrinsic during custom intrinsic selection (PR #83498)

Evgenii Kudriashov via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 13:25:17 PST 2024


================
@@ -1843,7 +1843,7 @@ bool X86InstructionSelector::selectIntrinsicWSideEffects(
   assert(I.getOpcode() == TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS &&
          "unexpected instruction");
 
-  if (I.getOperand(0).getIntrinsicID() != Intrinsic::trap)
+  if (cast<GIntrinsic>(I).getIntrinsicID() != Intrinsic::trap)
----------------
e-kud wrote:

That's interesting. It seems that `llvm.trap` is a special case as well as `llvm.debugtrap` and `llvm.ubsantrap`. Comparing to other intrinsics we can't lower it into combination of GlobalISel opcodes. So it is alive until instruction selection and then we custom select it.

If we take a look at SelectionDAG it lowers the intrinsic into `ISD::TRAP`. It seems that we can create `G_TRAP/G_DEBUGTRAP/G_UBSANTRAP` opcodes and lower intrinsics during `irtranslator`. I see that only 3 targets have a custom lowering for traps: AArch64, X86 and RISCV. So it shouldn't be a problem to migrate them all at once to proper lowering. What do you think, does it worth it?

https://github.com/llvm/llvm-project/pull/83498


More information about the llvm-commits mailing list