From 695de7692c26f5cb57eb67edb6b9ccf6d0ddafa2 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Fri, 22 Nov 2013 23:07:45 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195513 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 13472f038d5..fb5bee2ede2 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -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); -- 2.11.0