Add independent controls for whether GCOV profiling should emit .gcno files or
authorNick Lewycky <nicholas@mxc.ca>
Thu, 21 Apr 2011 01:56:25 +0000 (01:56 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 21 Apr 2011 01:56:25 +0000 (01:56 +0000)
instrument the program to emit .gcda.
TODO: we should emit slightly different .gcda files when .gcno emission is off.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129903 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/LinkAllPasses.h
include/llvm/Transforms/Instrumentation.h
lib/Transforms/Instrumentation/GCOVProfiling.cpp

index 56c113b4528be54bd9990465d2d975ea66fd268b..88ee65ac311a395194b220cb45617bde2fba09d3 100644 (file)
@@ -70,7 +70,7 @@ namespace {
       (void) llvm::createEdgeProfilerPass();
       (void) llvm::createOptimalEdgeProfilerPass();
       (void) llvm::createPathProfilerPass();
-      (void) llvm::createGCOVProfilerPass();
+      (void) llvm::createGCOVProfilerPass(true, true);
       (void) llvm::createFunctionInliningPass();
       (void) llvm::createAlwaysInlinerPass();
       (void) llvm::createGlobalDCEPass();
index 3ef2f5a14d0d76f193ad1e326ba3d0adafe7bccf..088775a9dfe76cb4bdc2a4390b30383ef6f2224e 100644 (file)
@@ -28,7 +28,7 @@ ModulePass *createOptimalEdgeProfilerPass();
 ModulePass *createPathProfilerPass();
 
 // Insert GCOV profiling instrumentation
-ModulePass *createGCOVProfilerPass();
+ModulePass *createGCOVProfilerPass(bool EmitNotes = true, bool EmitData = true);
 
 } // End llvm namespace
 
index 4e63a43f831e35c633f15217b84a13371ab9951e..a3ad5fe2e2d8df20aae7f5635d6a575a0d6a099a 100644 (file)
@@ -43,7 +43,13 @@ namespace {
     bool runOnModule(Module &M);
   public:
     static char ID;
-    GCOVProfiler() : ModulePass(ID) {
+    GCOVProfiler()
+        : ModulePass(ID), EmitNotes(true), EmitData(true) {
+      initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());
+    }
+    GCOVProfiler(bool EmitNotes, bool EmitData)
+        : ModulePass(ID), EmitNotes(EmitNotes), EmitData(EmitData) {
+      assert((EmitNotes || EmitData) && "GCOVProfiler asked to do nothing?");
       initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());
     }
     virtual const char *getPassName() const {
@@ -70,6 +76,9 @@ namespace {
                                SmallVector<std::pair<GlobalVariable *,
                                                      uint32_t>, 8> &);
 
+    bool EmitNotes;
+    bool EmitData;
+
     Module *Mod;
     LLVMContext *Ctx;
   };
@@ -79,7 +88,9 @@ char GCOVProfiler::ID = 0;
 INITIALIZE_PASS(GCOVProfiler, "insert-gcov-profiling",
                 "Insert instrumentation for GCOV profiling", false, false)
 
-ModulePass *llvm::createGCOVProfilerPass() { return new GCOVProfiler(); }
+ModulePass *llvm::createGCOVProfilerPass(bool EmitNotes, bool EmitData) {
+  return new GCOVProfiler(EmitNotes, EmitData);
+}
 
 static DISubprogram FindSubprogram(DIScope scope) {
   while (!scope.isSubprogram()) {
@@ -301,8 +312,9 @@ bool GCOVProfiler::runOnModule(Module &M) {
   DebugInfoFinder DIF;
   DIF.processModule(*Mod);
 
-  EmitGCNO(DIF);
-  return EmitProfileArcs(DIF);
+  if (EmitNotes) EmitGCNO(DIF);
+  if (EmitData) return EmitProfileArcs(DIF);
+  return false;
 }
 
 void GCOVProfiler::EmitGCNO(DebugInfoFinder &DIF) {