summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2019-01-04 19:04:54 +0000
committerTeresa Johnson <tejohnson@google.com>2019-01-04 19:04:54 +0000
commit853b962416bcb5c85df455eb4d89c896f9147ee8 (patch)
treee470c0dffcc023c6b58014e1d85abb3265aeb6c5 /llvm/lib/Transforms/IPO
parent1e36882b5291d5a7209be4f9c99b9713828afac4 (diff)
downloadbcm5719-llvm-853b962416bcb5c85df455eb4d89c896f9147ee8.tar.gz
bcm5719-llvm-853b962416bcb5c85df455eb4d89c896f9147ee8.zip
[ThinLTO] Handle chains of aliases
At -O0, globalopt is not run during the compile step, and we can have a chain of an alias having an immediate aliasee of another alias. The summaries are constructed assuming aliases in a canonical form (flattened chains), and as a result only the base object but no intermediate aliases were preserved. Fix by adding a pass that canonicalize aliases, which ensures each alias is a direct alias of the base object. Reviewers: pcc, davidxl Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D54507 llvm-svn: 350423
Diffstat (limited to 'llvm/lib/Transforms/IPO')
-rw-r--r--llvm/lib/Transforms/IPO/PassManagerBuilder.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index 60bd6def6ce..9764944dc33 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -462,12 +462,14 @@ void PassManagerBuilder::populateModulePassManager(
addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
- // Rename anon globals to be able to export them in the summary.
- // This has to be done after we add the extensions to the pass manager
- // as there could be passes (e.g. Adddress sanitizer) which introduce
- // new unnamed globals.
- if (PrepareForLTO || PrepareForThinLTO)
+ if (PrepareForLTO || PrepareForThinLTO) {
+ MPM.add(createCanonicalizeAliasesPass());
+ // Rename anon globals to be able to export them in the summary.
+ // This has to be done after we add the extensions to the pass manager
+ // as there could be passes (e.g. Adddress sanitizer) which introduce
+ // new unnamed globals.
MPM.add(createNameAnonGlobalPass());
+ }
return;
}
@@ -585,6 +587,7 @@ void PassManagerBuilder::populateModulePassManager(
// Ensure we perform any last passes, but do so before renaming anonymous
// globals in case the passes add any.
addExtensionsToPM(EP_OptimizerLast, MPM);
+ MPM.add(createCanonicalizeAliasesPass());
// Rename anon globals to be able to export them in the summary.
MPM.add(createNameAnonGlobalPass());
return;
@@ -744,9 +747,11 @@ void PassManagerBuilder::populateModulePassManager(
addExtensionsToPM(EP_OptimizerLast, MPM);
- // Rename anon globals to be able to handle them in the summary
- if (PrepareForLTO)
+ if (PrepareForLTO) {
+ MPM.add(createCanonicalizeAliasesPass());
+ // Rename anon globals to be able to handle them in the summary
MPM.add(createNameAnonGlobalPass());
+ }
}
void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
OpenPOWER on IntegriCloud