[llvm] r281840 - [ThinLTO] Ensure anonymous globals renamed even at -O0
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 17 13:40:17 PDT 2016
Author: tejohnson
Date: Sat Sep 17 15:40:16 2016
New Revision: 281840
URL: http://llvm.org/viewvc/llvm-project?rev=281840&view=rev
Log:
[ThinLTO] Ensure anonymous globals renamed even at -O0
Summary:
This fixes an issue when files are compiled with -flto=thin
at default -O0. We need to rename anonymous globals before attempting
to write the module summary because all values need names for
the summary. This was happening at -O1 and above, but not before
the early exit when constructing the pipeline for -O0.
Also add an internal -prepare-for-thinlto option to enable this
to be tested via opt.
Fixes PR30419.
Reviewers: mehdi_amini
Subscribers: probinson, llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D24701
Modified:
llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/trunk/test/Transforms/NameAnonGlobals/rename.ll
Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=281840&r1=281839&r2=281840&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Sat Sep 17 15:40:16 2016
@@ -112,6 +112,10 @@ static cl::opt<bool> EnableLoopLoadElim(
"enable-loop-load-elim", cl::init(true), cl::Hidden,
cl::desc("Enable the LoopLoadElimination Pass"));
+static cl::opt<bool>
+ EnablePrepareForThinLTO("prepare-for-thinlto", cl::init(false), cl::Hidden,
+ cl::desc("Enable preparation for ThinLTO."));
+
static cl::opt<bool> RunPGOInstrGen(
"profile-generate", cl::init(false), cl::Hidden,
cl::desc("Enable PGO instrumentation."));
@@ -163,7 +167,7 @@ PassManagerBuilder::PassManagerBuilder()
EnablePGOInstrGen = RunPGOInstrGen;
PGOInstrGen = PGOOutputFile;
PGOInstrUse = RunPGOInstrUse;
- PrepareForThinLTO = false;
+ PrepareForThinLTO = EnablePrepareForThinLTO;
PerformThinLTO = false;
}
@@ -395,6 +399,10 @@ void PassManagerBuilder::populateModuleP
else if (!GlobalExtensions->empty() || !Extensions.empty())
MPM.add(createBarrierNoopPass());
+ if (PrepareForThinLTO)
+ // Rename anon globals to be able to export them in the summary.
+ MPM.add(createNameAnonGlobalPass());
+
addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
return;
}
Modified: llvm/trunk/test/Transforms/NameAnonGlobals/rename.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/NameAnonGlobals/rename.ll?rev=281840&r1=281839&r2=281840&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/NameAnonGlobals/rename.ll (original)
+++ llvm/trunk/test/Transforms/NameAnonGlobals/rename.ll Sat Sep 17 15:40:16 2016
@@ -1,4 +1,5 @@
; RUN: opt -S -name-anon-globals < %s | FileCheck %s
+; RUN: opt -prepare-for-thinlto -O0 -module-summary -o %t.bc < %s
; foo contribute to the unique hash for the module
More information about the llvm-commits
mailing list