[PATCH] D53593: [GCOV] Flush counters before forking to avoid counting the execution before fork twice

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 26 14:39:15 PDT 2018


vsk added a comment.

Don't you just want to reset the counters in the child process?



================
Comment at: lib/Transforms/Instrumentation/GCOVProfiling.cpp:535
+    for (auto &BB : F) {
+      for (auto &I : BB) {
+        if (CallInst *CI = dyn_cast<CallInst>(&I)) {
----------------
See InstIterator.h. The instructions() range helper might be more convenient.


================
Comment at: lib/Transforms/Instrumentation/GCOVProfiling.cpp:541
+              if (FT->getReturnType()->isIntegerTy(32) &&
+                  FT->getNumParams() == 0) {
+                Forks.push_back(&I);
----------------
Take a look at TargetLibraryInfo.{h, def}. It might be cleaner to define fork() there, then check if you see a LibFunc_fork.


================
Comment at: lib/Transforms/Instrumentation/GCOVProfiling.cpp:556
+    Builder.CreateCall(GCOVFlush);
+    I->getParent()->splitBasicBlock(I);
+  }
----------------
Why is this needed?


Repository:
  rL LLVM

https://reviews.llvm.org/D53593





More information about the llvm-commits mailing list