Update pass status for GCOVProfiling
authorserge-sans-paille <sguelton@redhat.com>
Fri, 5 Jun 2020 07:08:06 +0000 (09:08 +0200)
committerserge-sans-paille <sguelton@redhat.com>
Tue, 9 Jun 2020 12:23:30 +0000 (14:23 +0200)
Take fork/exec instrumentation into account.

Differential Revision: https://reviews.llvm.org/D81227

llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

index 8c4ba2b..3a94096 100644 (file)
@@ -132,7 +132,7 @@ private:
   Function *insertReset(ArrayRef<std::pair<GlobalVariable *, MDNode *>>);
   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<CallInst *, 2> Forks;
   SmallVector<CallInst *, 2> 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() {