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

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 27 12:09:53 PST 2023


reames updated this revision to Diff 492877.
reames added a comment.

Add back faulting_op special case since my attempt at doing an NFC cleanup wasn't NFC on all targets.


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.492877.patch
Type: text/x-patch
Size: 784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230127/3f1c3b70/attachment.bin>


More information about the llvm-commits mailing list