[llvm] r271062 - [PM] Port the Sample FDO to new PM (part-1)

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Fri May 27 15:56:20 PDT 2016


 Will cleanup in the next patch.

thanks,

David

On Fri, May 27, 2016 at 3:54 PM, Davide Italiano <davide at freebsd.org> wrote:

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


More information about the llvm-commits mailing list