This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGc7f91e227a79: [InstrProfiling] No runtime hook for unused funcs (authored by gulfem).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122336/new/ https://reviews.llvm.org/D122336 Files: clang/test/CoverageMapping/unused_function_no_runtime_hook.cpp 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 @@ -558,16 +558,18 @@ TT = Triple(M.getTargetTriple()); bool MadeChange = false; - - // Emit the runtime hook even if no counters are present. - if (needsRuntimeHookUnconditionally(TT)) + bool NeedsRuntimeHook = needsRuntimeHookUnconditionally(TT); + if (NeedsRuntimeHook) MadeChange = emitRuntimeHook(); // Improve compile time by avoiding linear scans when there is no work. GlobalVariable *CoverageNamesVar = M.getNamedGlobal(getCoverageUnusedNamesVarName()); - if (!containsProfilingIntrinsics(M) && !CoverageNamesVar) - return MadeChange; + if (!containsProfilingIntrinsics(M)) { + if (!CoverageNamesVar || !NeedsRuntimeHook) { + return MadeChange; + } + } // We did not know how many value sites there would be inside // the instrumented function. This is counting the number of instrumented Index: clang/test/CoverageMapping/unused_function_no_runtime_hook.cpp =================================================================== --- /dev/null +++ clang/test/CoverageMapping/unused_function_no_runtime_hook.cpp @@ -0,0 +1,6 @@ +// RUN: %clang -target x86_64-unknown-fuchsia -fprofile-instr-generate -fcoverage-mapping -emit-llvm -S %s -o - | FileCheck %s + +// CHECK-NOT: @__llvm_profile_runtime +static int f0() { + return 100; +}
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -558,16 +558,18 @@ TT = Triple(M.getTargetTriple()); bool MadeChange = false; - - // Emit the runtime hook even if no counters are present. - if (needsRuntimeHookUnconditionally(TT)) + bool NeedsRuntimeHook = needsRuntimeHookUnconditionally(TT); + if (NeedsRuntimeHook) MadeChange = emitRuntimeHook(); // Improve compile time by avoiding linear scans when there is no work. GlobalVariable *CoverageNamesVar = M.getNamedGlobal(getCoverageUnusedNamesVarName()); - if (!containsProfilingIntrinsics(M) && !CoverageNamesVar) - return MadeChange; + if (!containsProfilingIntrinsics(M)) { + if (!CoverageNamesVar || !NeedsRuntimeHook) { + return MadeChange; + } + } // We did not know how many value sites there would be inside // the instrumented function. This is counting the number of instrumented Index: clang/test/CoverageMapping/unused_function_no_runtime_hook.cpp =================================================================== --- /dev/null +++ clang/test/CoverageMapping/unused_function_no_runtime_hook.cpp @@ -0,0 +1,6 @@ +// RUN: %clang -target x86_64-unknown-fuchsia -fprofile-instr-generate -fcoverage-mapping -emit-llvm -S %s -o - | FileCheck %s + +// CHECK-NOT: @__llvm_profile_runtime +static int f0() { + return 100; +}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits