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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to