[llvm] 5bdf22e - [InstrProfiling] Fix emitting runtime hook once
Gulfem Savrun Yeniceri via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 28 18:22:00 PDT 2022
Author: Gulfem Savrun Yeniceri
Date: 2022-09-29T01:21:49Z
New Revision: 5bdf22e743dbabdddd106f289a0f2d2f04c09b32
URL: https://github.com/llvm/llvm-project/commit/5bdf22e743dbabdddd106f289a0f2d2f04c09b32
DIFF: https://github.com/llvm/llvm-project/commit/5bdf22e743dbabdddd106f289a0f2d2f04c09b32.diff
LOG: [InstrProfiling] Fix emitting runtime hook once
https://reviews.llvm.org/D134254 introduced an issue on Fuchsia
target, which does not unconditionally emit runtime hook.
It used containsProfilingIntrinsics(M) after intrinsics are lowered.
So, this patch fixes the issue by capturing the result of that
function invocation before intrinsics are lowered.
Differential Revision: https://reviews.llvm.org/D134841
Added:
Modified:
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index a0041fc51949..7d54a9b97b9a 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -529,10 +529,11 @@ bool InstrProfiling::run(
if (NeedsRuntimeHook)
MadeChange = emitRuntimeHook();
- // Improve compile time by avoiding linear scans when there is no work.
+ bool ContainsProfiling = containsProfilingIntrinsics(M);
GlobalVariable *CoverageNamesVar =
M.getNamedGlobal(getCoverageUnusedNamesVarName());
- if (!containsProfilingIntrinsics(M) && !CoverageNamesVar)
+ // Improve compile time by avoiding linear scans when there is no work.
+ if (!ContainsProfiling && !CoverageNamesVar)
return MadeChange;
// We did not know how many value sites there would be inside
@@ -571,7 +572,7 @@ bool InstrProfiling::run(
// require pulling in profile runtime, and coverage is enabled on code that is
// not eliminated by the front-end, e.g. unused functions with internal
// linkage.
- if (!NeedsRuntimeHook && containsProfilingIntrinsics(M))
+ if (!NeedsRuntimeHook && ContainsProfiling)
emitRuntimeHook();
emitRegistration();
More information about the llvm-commits
mailing list