diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-12-10 21:49:28 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-12-10 21:49:28 +0000 |
commit | 30b2a9a59f6276ae76f45a5e8f7865c265b40822 (patch) | |
tree | 7f6fe585c4663ae174d5ae44c6d65d6a3fe6469a /llvm/lib | |
parent | eaa3a7efab65d0a65ddda7fdb7e5fbdbd5f897ad (diff) | |
download | bcm5719-llvm-30b2a9a59f6276ae76f45a5e8f7865c265b40822.tar.gz bcm5719-llvm-30b2a9a59f6276ae76f45a5e8f7865c265b40822.zip |
[asan] Fix the coverage.cc test broken by r196939
It was failing because ASan was adding all of the following to one
function:
- dynamic alloca
- stack realignment
- inline asm
This patch avoids making the static alloca dynamic when coverage is
used.
ASan should probably not be inserting empty inline asm blobs to inhibit
duplicate tail elimination.
llvm-svn: 196973
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 0b3ee861143..f683bfb16c7 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1167,7 +1167,19 @@ bool AddressSanitizer::maybeInsertAsanInitAtFunctionEntry(Function &F) { // b) collect usage statistics to help improve Clang coverage design. bool AddressSanitizer::InjectCoverage(Function &F) { if (!ClCoverage) return false; - IRBuilder<> IRB(F.getEntryBlock().getFirstInsertionPt()); + + // Skip static allocas at the top of the entry block so they don't become + // dynamic when we split the block. If we used our optimized stack layout, + // then there will only be one alloca and it will come first. + BasicBlock &Entry = F.getEntryBlock(); + BasicBlock::iterator IP = Entry.getFirstInsertionPt(), BE = Entry.end(); + for (; IP != BE; ++IP) { + AllocaInst *AI = dyn_cast<AllocaInst>(IP); + if (!AI || !AI->isStaticAlloca()) + break; + } + + IRBuilder<> IRB(IP); Type *Int8Ty = IRB.getInt8Ty(); GlobalVariable *Guard = new GlobalVariable( *F.getParent(), Int8Ty, false, GlobalValue::PrivateLinkage, |