From b4a44570f61681663b47486ffce749e9e8b6e46c Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 30 Jan 2015 13:33:42 +0000 Subject: [PATCH] [PM] Sink the population of the pass manager with target-specific analyses back into the LTO code generator. The pass manager builder (and the transforms library in general) shouldn't be referencing the target machine at all. This makes the LTO population work like the others -- the data layout and target transform info need to be pre-populated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227576 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/IPO/PassManagerBuilder.h | 2 +- lib/LTO/LTOCodeGenerator.cpp | 5 ++++- lib/Transforms/IPO/PassManagerBuilder.cpp | 8 +------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/llvm/Transforms/IPO/PassManagerBuilder.h b/include/llvm/Transforms/IPO/PassManagerBuilder.h index 68d750bf60d..2e6ec4133f4 100644 --- a/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -151,7 +151,7 @@ public: /// populateModulePassManager - This sets up the primary pass manager. void populateModulePassManager(PassManagerBase &MPM); - void populateLTOPassManager(PassManagerBase &PM, TargetMachine *TM = nullptr); + void populateLTOPassManager(PassManagerBase &PM); }; /// Registers a function for adding a standard set of passes. This should be diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index 3be805672d6..e0fcdec8ad0 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -488,6 +488,9 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out, // Add an appropriate DataLayout instance for this module... mergedModule->setDataLayout(TargetMach->getDataLayout()); + passes.add(new DataLayoutPass()); + TargetMach->addAnalysisPasses(passes); + Triple TargetTriple(TargetMach->getTargetTriple()); PassManagerBuilder PMB; PMB.DisableGVNLoadPRE = DisableGVNLoadPRE; @@ -501,7 +504,7 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out, PMB.VerifyInput = true; PMB.VerifyOutput = true; - PMB.populateLTOPassManager(passes, TargetMach); + PMB.populateLTOPassManager(passes); PassManager codeGenPasses; diff --git a/lib/Transforms/IPO/PassManagerBuilder.cpp b/lib/Transforms/IPO/PassManagerBuilder.cpp index 937155810b2..482a5e2ff6c 100644 --- a/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -478,13 +478,7 @@ void PassManagerBuilder::addLTOOptimizationPasses(PassManagerBase &PM) { PM.add(createMergeFunctionsPass()); } -void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM, - TargetMachine *TM) { - if (TM) { - PM.add(new DataLayoutPass()); - TM->addAnalysisPasses(PM); - } - +void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM) { if (LibraryInfo) PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));