[clang] [llvm] [SPIR-V] Add SPIR-V structurizer (PR #107408)

Nathan Gauër via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 08:13:32 PDT 2024


Keenuts wrote:

Rebased on main.
Also had to apply a few changes:
 - fixed valid expensive checks issues caused by this PR (irreflexible iterator)
This was because the BB order check was saying `A < A`.
 - fixed codegen instability caused by the block sorting.
 
 To satisfy both the SPIR-V spec and the MIR requirements, I had to be stricter on the block-ordering. The initial sorting I had was incomplete, and I had to use the partial topological sorting. But this sorting had a slight issue: when 2 BB had the same order, their order was not defined (same rank). I added the traversal index in addition to consistently compare those blocks.

@VyacheslavLevytskyy There is one test I disabled: `instructions/ret-type.ll`.
The failure can be avoided by not calling `sortBlocks` in `SPIRVPrepareFunction.cpp`.
I checked the IR, and it seems the only change is that the true label is sorted before the false label. And seems like the pointer type deduction fails in that case. Let me know if that's OK with you.


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


More information about the cfe-commits mailing list