diff options
author | Vedant Kumar <vsk@apple.com> | 2018-01-26 23:54:24 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-01-26 23:54:24 +0000 |
commit | 1ee511c19c72f0c3dedfd769cc6e370cd308c240 (patch) | |
tree | bc87e0c3ba721b7b52d207374b9f34d5c96a3c10 /llvm | |
parent | 5db11e31818ea3723cf500822e8d3f748ff0e34b (diff) | |
download | bcm5719-llvm-1ee511c19c72f0c3dedfd769cc6e370cd308c240.tar.gz bcm5719-llvm-1ee511c19c72f0c3dedfd769cc6e370cd308c240.zip |
[InstrProfiling] Improve compile time when there is no work
When there are no uses of profiling intrinsics in a module, and there's
no coverage data to lower, InstrProfiling has no work to do.
llvm-svn: 323574
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index 9b70f95480e..fcc07ee4555 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -430,7 +430,27 @@ void InstrProfiling::promoteCounterLoadStores(Function *F) { } } +/// Check if the module contains uses of any profiling intrinsics. +static bool containsProfilingIntrinsics(Module &M) { + if (auto *F = M.getFunction( + Intrinsic::getName(llvm::Intrinsic::instrprof_increment))) + return !F->use_empty(); + if (auto *F = M.getFunction( + Intrinsic::getName(llvm::Intrinsic::instrprof_increment_step))) + return !F->use_empty(); + if (auto *F = M.getFunction( + Intrinsic::getName(llvm::Intrinsic::instrprof_value_profile))) + return !F->use_empty(); + return false; +} + bool InstrProfiling::run(Module &M, const TargetLibraryInfo &TLI) { + // Improve compile time by avoiding linear scans when there is no work. + GlobalVariable *CoverageNamesVar = + M.getNamedGlobal(getCoverageUnusedNamesVarName()); + if (!containsProfilingIntrinsics(M) && !CoverageNamesVar) + return false; + bool MadeChange = false; this->M = &M; @@ -464,8 +484,7 @@ bool InstrProfiling::run(Module &M, const TargetLibraryInfo &TLI) { for (Function &F : M) MadeChange |= lowerIntrinsics(&F); - if (GlobalVariable *CoverageNamesVar = - M.getNamedGlobal(getCoverageUnusedNamesVarName())) { + if (CoverageNamesVar) { lowerCoverageData(CoverageNamesVar); MadeChange = true; } |