[PATCH] D142778: [BranchRelaxation] Strengthen post condition assertions
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 27 11:47:32 PST 2023
reames created this revision.
reames added reviewers: craig.topper, asb, luke, jrtc27, kito-cheng.
Herald added subscribers: bollu, hiraditya, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added a project: LLVM.
The whole point of this pass is to rewrite branches so that branches are in bounds. We should assert that we succeeded rather than just that we kept our internal data structure in sync.
Repository:
rG LLVM Github Monorepo
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,17 @@
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;
+ MachineBasicBlock *DestBB = TII->getBranchDestBlock(MI);
+ assert(isBlockInRange(MI, *DestBB));
+ }
+ }
#endif
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142778.492869.patch
Type: text/x-patch
Size: 709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230127/23e901bb/attachment.bin>
More information about the llvm-commits
mailing list