From ef1a7f2f01dbd15b1a6cb16141ae0ced2f7b6603 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Fri, 5 Jun 2020 09:08:06 +0200 Subject: [PATCH] Update pass status for GCOVProfiling Take fork/exec instrumentation into account. Differential Revision: https://reviews.llvm.org/D81227 --- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 8c4ba2b..3a94096 100644 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -132,7 +132,7 @@ private: 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 @@ bool GCOVProfiler::runOnModule( 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 @@ static bool shouldKeepInEntry(BasicBlock::iterator It) { return false; } -void GCOVProfiler::AddFlushBeforeForkAndExec() { +bool GCOVProfiler::AddFlushBeforeForkAndExec() { SmallVector Forks; SmallVector Execs; for (auto &F : M->functions()) { @@ -692,6 +693,8 @@ void GCOVProfiler::AddFlushBeforeForkAndExec() { Parent->splitBasicBlock(NextInst); Parent->back().setDebugLoc(Loc); } + + return !Forks.empty() || !Execs.empty(); } void GCOVProfiler::emitProfileNotes() { -- 2.7.4