diff options
| author | Teresa Johnson <tejohnson@google.com> | 2016-09-17 20:40:16 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2016-09-17 20:40:16 +0000 |
| commit | fbb431b292ea2e68dec8f504373c73adb9e7ae47 (patch) | |
| tree | cdbcbdda2ff9bce97891db5a87319f927cc03a19 /llvm | |
| parent | d4473f11260a0a12f8da24823bf4a44ab98436ce (diff) | |
| download | bcm5719-llvm-fbb431b292ea2e68dec8f504373c73adb9e7ae47.tar.gz bcm5719-llvm-fbb431b292ea2e68dec8f504373c73adb9e7ae47.zip | |
[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
llvm-svn: 281840
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | 10 | ||||
| -rw-r--r-- | llvm/test/Transforms/NameAnonGlobals/rename.ll | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 9bd9180eff7..cf8348f2dec 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -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::populateModulePassManager( 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; } diff --git a/llvm/test/Transforms/NameAnonGlobals/rename.ll b/llvm/test/Transforms/NameAnonGlobals/rename.ll index 996dc51800f..74fb972e756 100644 --- a/llvm/test/Transforms/NameAnonGlobals/rename.ll +++ b/llvm/test/Transforms/NameAnonGlobals/rename.ll @@ -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 |

