[llvm] r195513 - llvm-cov: Split entry blocks in GCNOProfiling.cpp.

Yuchen Wu yuchenericwu at hotmail.com
Fri Nov 22 15:07:45 PST 2013


Author: ywu
Date: Fri Nov 22 17:07:45 2013
New Revision: 195513

URL: http://llvm.org/viewvc/llvm-project?rev=195513&view=rev
Log:
llvm-cov: Split entry blocks in GCNOProfiling.cpp.

gcov expects every function to contain an entry block that
unconditionally branches into the next block. clang does not implement
basic blocks in this manner, so gcov did not output correct branch info
if the entry block branched to multiple blocks.

This change splits every function's entry block into an empty block and
a block with the rest of the instructions. The instrumentation code will
take care of the rest.

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=195513&r1=195512&r2=195513&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Fri Nov 22 17:07:45 2013
@@ -467,6 +467,9 @@ void GCOVProfiler::emitProfileNotes() {
 
       Function *F = SP.getFunction();
       if (!F) continue;
+      BasicBlock &EntryBlock = F->getEntryBlock();
+      EntryBlock.splitBasicBlock(EntryBlock.begin());
+
       GCOVFunction *Func =
         new GCOVFunction(SP, &out, i, Options.UseCfgChecksum);
       Funcs.push_back(Func);





More information about the llvm-commits mailing list