diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -839,6 +839,12 @@ } } +static bool isValueProfilingDisabled(const Module *M) { + Triple TT(M->getTargetTriple()); + // Fuchsia uses runtime counter relocation by default. + return TT.isOSFuchsia() || DisableValueProfiling; +} + // Visit all edge and instrument the edges not in MST, and do value profiling. // Critical edges will be split. static void instrumentOneFunc( @@ -890,7 +896,7 @@ FuncInfo.FunctionHash); assert(I == NumCounters); - if (DisableValueProfiling) + if (isValueProfilingDisabled(M)) return; NumOfPGOICall += FuncInfo.ValueSites[IPVK_IndirectCallTarget].size(); @@ -1774,7 +1780,7 @@ // Traverse all valuesites and annotate the instructions for all value kind. void PGOUseFunc::annotateValueSites() { - if (DisableValueProfiling) + if (isValueProfilingDisabled(M)) return; // Create the PGOFuncName meta data.