[clang] [flang] [llvm] [mlir] [OMPIRBuilder] always leave PARALLEL via the same barrier (PR #164586)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 08:16:19 PST 2025
https://github.com/Meinersbur commented:
For avoiding emitting finalization code multiple times, Clang generates code like this:
```
ExitingBB1:
br label %FiniBB
Exiting BB2:
br label %FiniBB
FiniBB:
%origin = phi i32 [%ExitingBB1, 0], [%ExitingBB2, 1]
... finalization code (calling dtors etc.) ...
switch i32 %origin
[0, label %ExitBB1],
[1, label %ExitBB2]
ExitBB1:
...
ExitBB2:
...
```
If I read the code correctly, `mergeFiniBB` merges all previous FiniBBs into the new OtherFiniBB (why not make the new code use the existing pre-FiniBB by emitting a branch to it?), and therefore effectively requires that all FiniBBs branch to the the same exit. If so, could you add a comment for that (in addition to "must not contain any non-finalization code")?
https://github.com/llvm/llvm-project/pull/164586
More information about the llvm-commits
mailing list