[PATCH] D142778: [BranchRelaxation] Strengthen post condition assertions

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 08:05:55 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG03bb277f308e: [BranchRelaxation] Strengthen post condition assertions (authored by reames).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142778/new/

https://reviews.llvm.org/D142778

Files:
  llvm/lib/CodeGen/BranchRelaxation.cpp


Index: llvm/lib/CodeGen/BranchRelaxation.cpp
===================================================================
--- llvm/lib/CodeGen/BranchRelaxation.cpp
+++ llvm/lib/CodeGen/BranchRelaxation.cpp
@@ -132,6 +132,19 @@
     assert(BlockInfo[Num].Size == computeBlockSize(MBB));
     PrevNum = Num;
   }
+
+  for (MachineBasicBlock &MBB : *MF) {
+    for (MachineBasicBlock::iterator J = MBB.getFirstTerminator();
+         J != MBB.end(); J = std::next(J)) {
+      MachineInstr &MI = *J;
+      if (!MI.isConditionalBranch() && !MI.isUnconditionalBranch())
+        continue;
+      if (MI.getOpcode() == TargetOpcode::FAULTING_OP)
+        continue;
+      MachineBasicBlock *DestBB = TII->getBranchDestBlock(MI);
+      assert(isBlockInRange(MI, *DestBB));
+    }
+  }
 #endif
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142778.493624.patch
Type: text/x-patch
Size: 784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230131/ca6c0ef5/attachment.bin>


More information about the llvm-commits mailing list