[PATCH] D134841: [InstrProfiling] Fix emitting runtime hook once

Gulfem Savrun Yeniceri via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 28 16:56:05 PDT 2022


gulfem created this revision.
Herald added subscribers: Enna1, ellis, hiraditya.
Herald added a project: All.
gulfem requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134841

Files:
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp


Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -529,10 +529,11 @@
   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 @@
   // 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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134841.463717.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220928/7d883a5e/attachment.bin>


More information about the llvm-commits mailing list