diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index ce9972888e8920..a0041fc5194959 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -567,11 +567,11 @@ bool InstrProfiling::run( emitVNodes(); emitNameData(); - // Emit runtime hook except for the cases where 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. - if (containsProfilingIntrinsics(M) || !CoverageNamesVar || NeedsRuntimeHook) + // Emit runtime hook for the cases where the target does not unconditionally + // 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)) emitRuntimeHook(); emitRegistration();