[llvm] [AMDGPU] Add a trap lowering workaround for gfx11 (PR #85854)

Scott Linder via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 12:04:58 PDT 2024


================
@@ -6720,8 +6720,14 @@ bool AMDGPULegalizerInfo::legalizeTrapHsaQueuePtr(
 
 bool AMDGPULegalizerInfo::legalizeTrapHsa(
     MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &B) const {
-  B.buildInstr(AMDGPU::S_TRAP)
-      .addImm(static_cast<unsigned>(GCNSubtarget::TrapID::LLVMAMDHSATrap));
+  if (!ST.requiresSimulatedTrap()) {
----------------
slinder1 wrote:

Nit, but it seems like the exceptional case would be better to have the early return for, i.e.

```
if (requiresSimulatedTrap) {
  insertSimulatedTrap()
 return true;
}
buildTrap()
```

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


More information about the llvm-commits mailing list