summaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation/AddressSanitizer.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2013-12-10 21:49:28 +0000
committerReid Kleckner <reid@kleckner.net>2013-12-10 21:49:28 +0000
commit0e33b4574b02c0a152567bbc384ba22f727851e8 (patch)
tree2b07fcb78d8d0c9da7c49abc9d6c2502b9f6ea6d /lib/Transforms/Instrumentation/AddressSanitizer.cpp
parent17427fa9bb0d4dad96270542184d2a28d5626c22 (diff)
downloadllvm-0e33b4574b02c0a152567bbc384ba22f727851e8.tar.gz
llvm-0e33b4574b02c0a152567bbc384ba22f727851e8.tar.bz2
llvm-0e33b4574b02c0a152567bbc384ba22f727851e8.tar.xz
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196973 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation/AddressSanitizer.cpp')
-rw-r--r--lib/Transforms/Instrumentation/AddressSanitizer.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 0b3ee86114..f683bfb16c 100644
--- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/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,