Revert "[InstrProfiling] No runtime hook for unused funcs"

This reverts commit c7f91e227a.
This patch caused an issue in Fuchsia source code coverage builders.
This commit is contained in:
Gulfem Savrun Yeniceri 2022-04-06 01:39:32 +00:00
parent 8a4d388c7f
commit bcf8f2188b
2 changed files with 5 additions and 15 deletions

View File

@ -1,6 +0,0 @@
// 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;
}

View File

@ -558,20 +558,16 @@ bool InstrProfiling::run(
TT = Triple(M.getTargetTriple());
bool MadeChange = false;
bool NeedsRuntimeHook = needsRuntimeHookUnconditionally(TT);
if (NeedsRuntimeHook)
// Emit the runtime hook even if no counters are present.
if (needsRuntimeHookUnconditionally(TT))
MadeChange = emitRuntimeHook();
// Improve compile time by avoiding linear scans when there is no work.
GlobalVariable *CoverageNamesVar =
M.getNamedGlobal(getCoverageUnusedNamesVarName());
// Improve compile time by avoiding linear scans when there is no work.
// When coverage is enabled on code that is eliminated by the front-end,
// e.g. unused functions with internal linkage, and the target does not
// require pulling in profile runtime, there is no need to do further work.
if (!containsProfilingIntrinsics(M) &&
(!CoverageNamesVar || !NeedsRuntimeHook)) {
if (!containsProfilingIntrinsics(M) && !CoverageNamesVar)
return MadeChange;
}
// We did not know how many value sites there would be inside
// the instrumented function. This is counting the number of instrumented