[llvm] [SPIR-V] Re-implement switch and improve validation of forward calls (PR #87823)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 09:39:08 PDT 2024


Keenuts wrote:

@VyacheslavLevytskyy 
Seems like using indirect branch to keep the CFG correct caused issues with the ASM printer:

Example building `switch-range-check.ll`
```
	OpReturn
Ltmp0:                                  ; Address of block that was removed by CodeGen
Ltmp1:                                  ; Address of block that was removed by CodeGen
Ltmp2:                                  ; Address of block that was removed by CodeGen
Ltmp3:                                  ; Address of block that was removed by CodeGen
Ltmp4:                                  ; Address of block that was removed by CodeGen
Ltmp5:                                  ; Address of block that was removed by CodeGen
Ltmp6:                                  ; Address of block that was removed by CodeGen
Ltmp7:                                  ; Address of block that was removed by CodeGen
Ltmp8:                                  ; Address of block that was removed by CodeGen
Ltmp9:                                  ; Address of block that was removed by CodeGen
Ltmp10:                                 ; Address of block that was removed by CodeGen
	OpFunctionEnd
```

Seems like the indirect branch is removed by the IRTranslator since the switch don't select it, but because the MBB/BBs are still marked as "AddressTaken", the asm printer generates bad labels.
The dirty solution I have locally is to modify the AsmPrinter and check for the triple before emitting this label+comment, but do you have an idea how to fix this?

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


More information about the llvm-commits mailing list