[PATCH] D127208: MachineSink debug invariance
Markus Lavin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 7 05:27:55 PDT 2022
markus created this revision.
markus added a reviewer: jmorse.
Herald added a subscriber: hiraditya.
Herald added a project: All.
markus requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
https://github.com/llvm/llvm-project/issues/55914
When counting instructions to compare with threshold debug instructions need to be ignored in order to be invariant wrt to debuginfo
https://reviews.llvm.org/D127208
Files:
llvm/lib/CodeGen/MachineSink.cpp
Index: llvm/lib/CodeGen/MachineSink.cpp
===================================================================
--- llvm/lib/CodeGen/MachineSink.cpp
+++ llvm/lib/CodeGen/MachineSink.cpp
@@ -268,6 +268,16 @@
INITIALIZE_PASS_END(MachineSinking, DEBUG_TYPE,
"Machine code sinking", false, false)
+static unsigned sizeNoDbg(const MachineBasicBlock &MBB) {
+ unsigned Size = 0;
+ for (auto &MI : MBB) {
+ if (MI.isDebugInstr())
+ continue;
+ Size++;
+ }
+ return Size;
+}
+
bool MachineSinking::PerformTrivialForwardCoalescing(MachineInstr &MI,
MachineBasicBlock *MBB) {
if (!MI.isCopy())
@@ -1175,7 +1185,7 @@
// If this BB is too big or the block number in straight line between From
// and To is too big, stop searching to save compiling time.
- if (BB->size() > SinkLoadInstsPerBlockThreshold ||
+ if (sizeNoDbg(*BB) > SinkLoadInstsPerBlockThreshold ||
HandledDomBlocks.size() > SinkLoadBlocksThreshold) {
for (auto *DomBB : HandledDomBlocks) {
if (DomBB != BB && DT->dominates(DomBB, BB))
@@ -1277,7 +1287,7 @@
dbgs() << "CycleSink: Not sinking, sink block is the preheader\n");
return false;
}
- if (SinkBlock->size() > SinkLoadInstsPerBlockThreshold) {
+ if (sizeNoDbg(*SinkBlock) > SinkLoadInstsPerBlockThreshold) {
LLVM_DEBUG(
dbgs() << "CycleSink: Not Sinking, block too large to analyse.\n");
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127208.434786.patch
Type: text/x-patch
Size: 1501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220607/8427695a/attachment.bin>
More information about the llvm-commits
mailing list