diff options
| author | Diego Novillo <dnovillo@google.com> | 2013-11-13 12:22:39 +0000 |
|---|---|---|
| committer | Diego Novillo <dnovillo@google.com> | 2013-11-13 12:22:39 +0000 |
| commit | b85a9ec6df63f30bbdef9a3975b1d31a680b15c1 (patch) | |
| tree | d6ffee22c60fa3ae4cb74605dfd217b43cb406db /lib/CodeGen/BackendUtil.cpp | |
| parent | d1fa81ccbce1ba2d8f467e7c2800250b81ea2e35 (diff) | |
| download | clang-b85a9ec6df63f30bbdef9a3975b1d31a680b15c1.tar.gz clang-b85a9ec6df63f30bbdef9a3975b1d31a680b15c1.tar.bz2 clang-b85a9ec6df63f30bbdef9a3975b1d31a680b15c1.tar.xz | |
Add -fprofile-sample-use to Clang's driver.
This adds a new option -fprofile-sample-use=filename to Clang. It
tells the driver to schedule the SampleProfileLoader pass and passes
on the name of the profile file to use.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194567 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/BackendUtil.cpp')
| -rw-r--r-- | lib/CodeGen/BackendUtil.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 7a62e4e195..e159a7ab5d 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -154,6 +154,14 @@ static void addObjCARCOptPass(const PassManagerBuilder &Builder, PassManagerBase PM.add(createObjCARCOptPass()); } +static void addSampleProfileLoaderPass(const PassManagerBuilder &Builder, + PassManagerBase &PM) { + const PassManagerBuilderWrapper &BuilderWrapper = + static_cast<const PassManagerBuilderWrapper &>(Builder); + const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); + PM.add(createSampleProfileLoaderPass(CGOpts.SampleProfileFile)); +} + static void addBoundsCheckingPass(const PassManagerBuilder &Builder, PassManagerBase &PM) { PM.add(createBoundsCheckingPass()); @@ -235,6 +243,10 @@ void EmitAssemblyHelper::CreatePasses(TargetMachine *TM) { PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtATime; PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops; + if (!CodeGenOpts.SampleProfileFile.empty()) + PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible, + addSampleProfileLoaderPass); + // In ObjC ARC mode, add the main ARC optimization passes. if (LangOpts.ObjCAutoRefCount) { PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible, |
