<div dir="ltr"> Will cleanup in the next patch.<div><br></div><div>thanks,</div><div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 27, 2016 at 3:54 PM, Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, May 27, 2016 at 3:30 PM, Xinliang David Li via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: davidxl<br>
> Date: Fri May 27 17:30:44 2016<br>
> New Revision: 271062<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=271062&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=271062&view=rev</a><br>
> Log:<br>
> [PM] Port the Sample FDO to new PM (part-1)<br>
><br>
> Modified:<br>
> llvm/trunk/include/llvm/InitializePasses.h<br>
> llvm/trunk/lib/Transforms/IPO/IPO.cpp<br>
> llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/InitializePasses.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=271062&r1=271061&r2=271062&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=271062&r1=271061&r2=271062&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/InitializePasses.h (original)<br>
> +++ llvm/trunk/include/llvm/InitializePasses.h Fri May 27 17:30:44 2016<br>
> @@ -70,7 +70,7 @@ void initializeAliasSetPrinterPass(PassR<br>
> void initializeAlwaysInlinerPass(PassRegistry&);<br>
> void initializeArgPromotionPass(PassRegistry&);<br>
> void initializeAtomicExpandPass(PassRegistry&);<br>
> -void initializeSampleProfileLoaderPass(PassRegistry&);<br>
> +void initializeSampleProfileLoaderLegacyPassPass(PassRegistry&);<br>
> void initializeAlignmentFromAssumptionsPass(PassRegistry&);<br>
> void initializeBarrierNoopPass(PassRegistry&);<br>
> void initializeBasicAAWrapperPassPass(PassRegistry&);<br>
><br>
> Modified: llvm/trunk/lib/Transforms/IPO/IPO.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IPO.cpp?rev=271062&r1=271061&r2=271062&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IPO.cpp?rev=271062&r1=271061&r2=271062&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Transforms/IPO/IPO.cpp (original)<br>
> +++ llvm/trunk/lib/Transforms/IPO/IPO.cpp Fri May 27 17:30:44 2016<br>
> @@ -52,7 +52,7 @@ void llvm::initializeIPO(PassRegistry &R<br>
> initializeStripNonDebugSymbolsPass(Registry);<br>
> initializeBarrierNoopPass(Registry);<br>
> initializeEliminateAvailableExternallyLegacyPassPass(Registry);<br>
> - initializeSampleProfileLoaderPass(Registry);<br>
> + initializeSampleProfileLoaderLegacyPassPass(Registry);<br>
> initializeFunctionImportPassPass(Registry);<br>
> initializeWholeProgramDevirtPass(Registry);<br>
> }<br>
><br>
> Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=271062&r1=271061&r2=271062&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=271062&r1=271061&r2=271062&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)<br>
> +++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Fri May 27 17:30:44 2016<br>
> @@ -101,26 +101,17 @@ typedef DenseMap<const BasicBlock *, Sma<br>
> /// This pass reads profile data from the file specified by<br>
> /// -sample-profile-file and annotates every affected function with the<br>
> /// profile information found in that file.<br>
> -class SampleProfileLoader : public ModulePass {<br>
> +class SampleProfileLoader {<br>
> public:<br>
> - // Class identification, replacement for typeinfo<br>
> - static char ID;<br>
> -<br>
> SampleProfileLoader(StringRef Name = SampleProfileFile)<br>
> - : ModulePass(ID), DT(nullptr), PDT(nullptr), LI(nullptr), Reader(),<br>
> - Samples(nullptr), Filename(Name), ProfileIsValid(false),<br>
> - TotalCollectedSamples(0) {<br>
> - initializeSampleProfileLoaderPass(*PassRegistry::getPassRegistry());<br>
> - }<br>
> + : DT(nullptr), PDT(nullptr), LI(nullptr), Reader(), Samples(nullptr),<br>
> + Filename(Name), ProfileIsValid(false), TotalCollectedSamples(0) {}<br>
><br>
> - bool doInitialization(Module &M) override;<br>
> + bool doInitialization(Module &M);<br>
> + bool runOnModule(Module &M);<br>
><br>
> void dump() { Reader->dump(); }<br>
><br>
> - const char *getPassName() const override { return "Sample profile pass"; }<br>
> -<br>
> - bool runOnModule(Module &M) override;<br>
> -<br>
> protected:<br>
> bool runOnFunction(Function &F);<br>
> unsigned getFunctionLoc(Function &F);<br>
> @@ -202,6 +193,29 @@ protected:<br>
> uint64_t TotalCollectedSamples;<br>
> };<br>
><br>
> +class SampleProfileLoaderLegacyPass : public ModulePass {<br>
> +public:<br>
> + // Class identification, replacement for typeinfo<br>
> + static char ID;<br>
> +<br>
> + SampleProfileLoaderLegacyPass(StringRef Name = SampleProfileFile)<br>
> + : ModulePass(ID), SampleLoader(Name) {<br>
> + initializeSampleProfileLoaderLegacyPassPass(<br>
> + *PassRegistry::getPassRegistry());<br>
> + }<br>
> +<br>
> + void dump() { SampleLoader.dump(); }<br>
> +<br>
> + bool doInitialization(Module &M) override {<br>
> + return SampleLoader.doInitialization(M);<br>
> + }<br>
> + const char *getPassName() const override { return "Sample profile pass"; }<br>
> + bool runOnModule(Module &M) override;<br>
> +<br>
> +private:<br>
> + SampleProfileLoader SampleLoader;<br>
> +};<br>
> +<br>
> class SampleCoverageTracker {<br>
> public:<br>
> SampleCoverageTracker() : SampleCoverage(), TotalUsedSamples(0) {}<br>
> @@ -1210,10 +1224,10 @@ bool SampleProfileLoader::emitAnnotation<br>
> return Changed;<br>
> }<br>
><br>
> -char SampleProfileLoader::ID = 0;<br>
> -INITIALIZE_PASS_BEGIN(SampleProfileLoader, "sample-profile",<br>
> +char SampleProfileLoaderLegacyPass::ID = 0;<br>
> +INITIALIZE_PASS_BEGIN(SampleProfileLoaderLegacyPass, "sample-profile",<br>
> "Sample Profile loader", false, false)<br>
> -INITIALIZE_PASS_END(SampleProfileLoader, "sample-profile",<br>
> +INITIALIZE_PASS_END(SampleProfileLoaderLegacyPass, "sample-profile",<br>
> "Sample Profile loader", false, false)<br>
><br>
<br>
As this pass has no more dependencies, the code above can simply just<br>
be INITIALIZE_PASS.<br>
<br>
Cheers,<br>
<br>
--<br>
Davide<br>
</blockquote></div><br></div>