diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -132,7 +132,7 @@ Function *insertReset(ArrayRef>); Function *insertFlush(Function *ResetF); - void AddFlushBeforeForkAndExec(); + bool AddFlushBeforeForkAndExec(); enum class GCovFileType { GCNO, GCDA }; std::string mangleName(const DICompileUnit *CU, GCovFileType FileType); @@ -554,14 +554,15 @@ this->GetTLI = std::move(GetTLI); Ctx = &M.getContext(); - AddFlushBeforeForkAndExec(); + bool Modified = AddFlushBeforeForkAndExec(); FilterRe = createRegexesFromString(Options.Filter); ExcludeRe = createRegexesFromString(Options.Exclude); if (Options.EmitNotes) emitProfileNotes(); - if (Options.EmitData) return emitProfileArcs(); - return false; + if (Options.EmitData) + Modified |= emitProfileArcs(); + return Modified; } PreservedAnalyses GCOVProfilerPass::run(Module &M, @@ -620,7 +621,7 @@ return false; } -void GCOVProfiler::AddFlushBeforeForkAndExec() { +bool GCOVProfiler::AddFlushBeforeForkAndExec() { SmallVector Forks; SmallVector Execs; for (auto &F : M->functions()) { @@ -692,6 +693,8 @@ Parent->splitBasicBlock(NextInst); Parent->back().setDebugLoc(Loc); } + + return !Forks.empty() || !Execs.empty(); } void GCOVProfiler::emitProfileNotes() {