-
Notifications
You must be signed in to change notification settings - Fork 15.4k
llvm-reduce: Preserve uselistorder when writing thinlto bitcode #133369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llvm-reduce: Preserve uselistorder when writing thinlto bitcode #133369
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@llvm/pr-subscribers-llvm-transforms Author: Matt Arsenault (arsenm) ChangesFixes #63621 Full diff: https://github.com/llvm/llvm-project/pull/133369.diff 2 Files Affected:
diff --git a/llvm/test/tools/llvm-reduce/thinlto-preserve-uselistorder.ll b/llvm/test/tools/llvm-reduce/thinlto-preserve-uselistorder.ll
new file mode 100644
index 0000000000000..2332f2d632911
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/thinlto-preserve-uselistorder.ll
@@ -0,0 +1,19 @@
+; RUN: opt --thinlto-bc --thinlto-split-lto-unit %s -o %t.0
+; RUN: llvm-reduce -write-tmp-files-as-bitcode --delta-passes=instructions %t.0 -o %t.1 \
+; RUN: --test %python --test-arg %p/Inputs/llvm-dis-and-filecheck.py --test-arg llvm-dis --test-arg FileCheck --test-arg --check-prefix=INTERESTING --test-arg %s
+; RUN: llvm-dis --preserve-ll-uselistorder %t.1 -o %t.2
+; RUN: FileCheck --check-prefix=RESULT %s < %t.2
+
+define i32 @func(i32 %arg0, i32 %arg1) {
+entry:
+ %add0 = add i32 %arg0, 0
+ %add1 = add i32 %add0, 0
+ %add2 = add i32 %add1, 0
+ %add3 = add i32 %arg1, 0
+ %add4 = add i32 %add2, %add3
+ ret i32 %add4
+}
+
+; INTERESTING: uselistorder i32 0
+; RESULT: uselistorder i32 0, { 0, 2, 1 }
+uselistorder i32 0, { 3, 2, 1, 0 }
diff --git a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
index ad40d8d8baa36..c93af57f0bd6f 100644
--- a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
+++ b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
@@ -769,6 +769,8 @@ void ReducerWorkItem::readBitcode(MemoryBufferRef Data, LLVMContext &Ctx,
}
void ReducerWorkItem::writeBitcode(raw_ostream &OutStream) const {
+ const bool ShouldPreserveUseListOrder = true;
+
if (LTOInfo && LTOInfo->IsThinLTO && LTOInfo->EnableSplitLTOUnit) {
PassBuilder PB;
LoopAnalysisManager LAM;
@@ -781,7 +783,8 @@ void ReducerWorkItem::writeBitcode(raw_ostream &OutStream) const {
PB.registerLoopAnalyses(LAM);
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
ModulePassManager MPM;
- MPM.addPass(ThinLTOBitcodeWriterPass(OutStream, nullptr));
+ MPM.addPass(ThinLTOBitcodeWriterPass(OutStream, nullptr,
+ ShouldPreserveUseListOrder));
MPM.run(*M, MAM);
} else {
std::unique_ptr<ModuleSummaryIndex> Index;
@@ -790,8 +793,8 @@ void ReducerWorkItem::writeBitcode(raw_ostream &OutStream) const {
Index = std::make_unique<ModuleSummaryIndex>(
buildModuleSummaryIndex(*M, nullptr, &PSI));
}
- WriteBitcodeToFile(getModule(), OutStream,
- /*ShouldPreserveUseListOrder=*/true, Index.get());
+ WriteBitcodeToFile(getModule(), OutStream, ShouldPreserveUseListOrder,
+ Index.get());
}
}
|
ad72c24 to
40a72c4
Compare
f323086 to
2df298a
Compare
40a72c4 to
ed69586
Compare
teresajohnson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm but please remove the FIXME for the reason noted below
2df298a to
660836c
Compare
7ad9df1 to
64c6fea
Compare
660836c to
d0e10cb
Compare
64c6fea to
f324dce
Compare
d0e10cb to
5b797c4
Compare
5b797c4 to
dae6bf4
Compare
f324dce to
610c0a0
Compare
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/16001 Here is the relevant piece of the build log for the reference |

Fixes #63621