diff options
author | Bob Wilson <bob.wilson@apple.com> | 2014-01-31 05:24:01 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2014-01-31 05:24:01 +0000 |
commit | 055a0b4ca21d2888311b4bb1819938309c0c3913 (patch) | |
tree | c736edc2dd59558a7e0cbe21d390715f3f2e2875 /llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp | |
parent | ebc13c47f2b7b87216adf16850ace17a28d5b18f (diff) | |
download | bcm5719-llvm-055a0b4ca21d2888311b4bb1819938309c0c3913.tar.gz bcm5719-llvm-055a0b4ca21d2888311b4bb1819938309c0c3913.zip |
Fix a bug in gcov instrumentation introduced by r195513. <rdar://15930350>
The entry block of a function starts with all the static allocas. The change
in r195513 splits the block before those allocas, which has the effect of
turning them into dynamic allocas. That breaks all sorts of things. Change to
split after the initial allocas, and also add a comment explaining why the
block is split.
llvm-svn: 200515
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 8d5a83ca23a..0929142108a 100644 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -27,6 +27,7 @@ #include "llvm/DebugInfo.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instructions.h" +#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" @@ -478,8 +479,14 @@ void GCOVProfiler::emitProfileNotes() { Function *F = SP.getFunction(); if (!F) continue; + + // gcov expects every function to start with an entry block that has a + // single successor, so split the entry block to make sure of that. BasicBlock &EntryBlock = F->getEntryBlock(); - EntryBlock.splitBasicBlock(EntryBlock.begin()); + BasicBlock::iterator It = EntryBlock.begin(); + while (isa<AllocaInst>(*It) || isa<DbgInfoIntrinsic>(*It)) + ++It; + EntryBlock.splitBasicBlock(It); GCOVFunction *Func = new GCOVFunction(SP, &out, i, Options.UseCfgChecksum); |