[Lldb-commits] [compiler-rt] [flang] [openmp] [clang-tools-extra] [mlir] [clang] [lldb] [llvm] [lld] [libunwind] [BranchFolding] Fix missing predecessors of landing-pad (PR #77608)

Phoebe Wang via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 11 01:03:08 PST 2024


================
@@ -1624,6 +1632,15 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
             } else {
               DidChange = true;
               PMBB->ReplaceUsesOfBlockWith(MBB, CurTBB);
+              // Add rest successors of MBB to successors of CurTBB. Those
+              // successors are not directly reachable via MBB, so it should be
+              // landing-pad.
+              for (auto SI = MBB->succ_begin(), SE = MBB->succ_end(); SI != SE;
+                   ++SI)
+                if (*SI != CurTBB && !CurTBB->isSuccessor(*SI)) {
+                  assert((*SI)->isEHPad() && "Bad CFG");
+                  CurTBB->copySuccessor(MBB, SI);
----------------
phoebewang wrote:

I see we assert for `(*SI)->isEHPad()`, but `bb.6` is not a EHPad. Did I misunderstand something here?
BTW, can we use `SI->isEHPad()` directly?

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


More information about the lldb-commits mailing list