From: Dehao Chen Date: Wed, 14 Dec 2016 21:40:47 +0000 (+0000) Subject: Create SampleProfileLoader pass in llvm instead of clang X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a99e082e15422bb2666532001bca76dbe30468bf;p=platform%2Fupstream%2Fllvm.git Create SampleProfileLoader pass in llvm instead of clang Summary: We used to create SampleProfileLoader pass in clang. This makes LTO/ThinLTO unable to add this pass in the linker plugin. This patch moves the SampleProfileLoader pass creation from clang to llvm pass manager builder. Reviewers: tejohnson, davidxl, dnovillo Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D27743 llvm-svn: 289714 --- diff --git a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h index adc4179..21f36b3 100644 --- a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -149,6 +149,8 @@ public: std::string PGOInstrGen; /// Path of the profile data file. std::string PGOInstrUse; + /// Path of the sample Profile data file. + std::string PGOSampleUse; private: /// ExtensionList - This is list of all of the extensions that are registered. diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 5c26c66..b0e4b11 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -383,6 +383,11 @@ void PassManagerBuilder::addFunctionSimplificationPasses( void PassManagerBuilder::populateModulePassManager( legacy::PassManagerBase &MPM) { + if (!PGOSampleUse.empty()) { + MPM.add(createPruneEHPass()); + MPM.add(createSampleProfileLoaderPass(PGOSampleUse)); + } + // Allow forcing function attributes as a debugging and tuning aid. MPM.add(createForceFunctionAttrsLegacyPass());