[PATCH] D130596: [StandardInstrumentations] Handle case where block order changes
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 26 13:07:13 PDT 2022
aeubanks created this revision.
aeubanks added a reviewer: jamieschmeiser.
Herald added a subscriber: hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Previously we'd go off the end of the BI iterator because we expected
that the relative positions of common blocks before and after were
consistent. That's not always true though, for example with
jump-threading.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130596
Files:
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/test/Other/ChangePrinters/print-changed-diff-block-ordering-changed.ll
Index: llvm/test/Other/ChangePrinters/print-changed-diff-block-ordering-changed.ll
===================================================================
--- /dev/null
+++ llvm/test/Other/ChangePrinters/print-changed-diff-block-ordering-changed.ll
@@ -0,0 +1,20 @@
+; RUN: opt -passes=jump-threading %s -disable-output --print-changed=diff 2>&1 | FileCheck %s
+
+; CHECK: IR Dump After JumpThreadingPass
+
+define void @f(i1 %0) {
+ br i1 %0, label %5, label %2
+
+2: ; preds = %1
+ br i1 false, label %b, label %3
+
+3: ; preds = %2
+ %4 = call i64 null()
+ br label %b
+
+b: ; preds = %3, %2
+ br label %5
+
+5: ; preds = %b, %1
+ ret void
+}
Index: llvm/lib/Passes/StandardInstrumentations.cpp
===================================================================
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -612,7 +612,10 @@
}
// This section is in both; advance and print out any before-only
// until we get to it.
- while (*BI != *AI) {
+ // It's possible that this section has moved to be later than before. This
+ // will mess up printing most blocks side by side, but it's a rare case and
+ // it's better than crashing.
+ while (BI != BE && *BI != *AI) {
HandlePotentiallyRemovedData(*BI);
++BI;
}
@@ -622,7 +625,6 @@
const T &AData = AFD.find(*AI)->getValue();
const T &BData = BFD.find(*AI)->getValue();
HandlePair(&BData, &AData);
- ++BI;
++AI;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130596.447810.patch
Type: text/x-patch
Size: 1683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220726/2a134f43/attachment.bin>
More information about the llvm-commits
mailing list