summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2013-06-26 09:49:52 +0000
committerKostya Serebryany <kcc@google.com>2013-06-26 09:49:52 +0000
commitd4429214a2dffcfd8f97956ac8b1a67c4795d242 (patch)
treefca1facc18e3437b8f5b092c3dda1db117d39eab
parent20985711c76b8799d689a9c0e416b68896333c23 (diff)
downloadllvm-d4429214a2dffcfd8f97956ac8b1a67c4795d242.tar.gz
llvm-d4429214a2dffcfd8f97956ac8b1a67c4795d242.tar.bz2
llvm-d4429214a2dffcfd8f97956ac8b1a67c4795d242.tar.xz
[asan] workaround for PR16277: don't instrument AllocaInstr with alignment more than the redzone size
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184928 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Instrumentation/AddressSanitizer.cpp3
-rw-r--r--test/Instrumentation/AddressSanitizer/basic.ll19
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 67a8325b0c..417fd76dc1 100644
--- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -451,7 +451,7 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
StackAlignment = std::max(StackAlignment, AI.getAlignment());
AllocaVec.push_back(&AI);
- uint64_t AlignedSize = getAlignedAllocaSize(&AI);
+ uint64_t AlignedSize = getAlignedAllocaSize(&AI);
TotalStackSize += AlignedSize;
}
@@ -488,6 +488,7 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
bool isInterestingAlloca(AllocaInst &AI) {
return (!AI.isArrayAllocation() &&
AI.isStaticAlloca() &&
+ AI.getAlignment() <= RedzoneSize() &&
AI.getAllocatedType()->isSized());
}
diff --git a/test/Instrumentation/AddressSanitizer/basic.ll b/test/Instrumentation/AddressSanitizer/basic.ll
index fb32e704af..6002b9e897 100644
--- a/test/Instrumentation/AddressSanitizer/basic.ll
+++ b/test/Instrumentation/AddressSanitizer/basic.ll
@@ -89,6 +89,25 @@ entry:
; CHECK-NOT: = alloca
; CHECK: ret void
+; Check that asan does not touch allocas with alignment > 32.
+define void @alloca_alignment_test() sanitize_address {
+entry:
+ %x = alloca [10 x i8], align 64
+ %y = alloca [10 x i8], align 128
+ %z = alloca [10 x i8], align 256
+ call void @alloca_test_use([10 x i8]* %x)
+ call void @alloca_test_use([10 x i8]* %y)
+ call void @alloca_test_use([10 x i8]* %z)
+ ret void
+}
+
+; CHECK: define void @alloca_alignment_test()
+; CHECK: = alloca{{.*}} align 64
+; CHECK: = alloca{{.*}} align 128
+; CHECK: = alloca{{.*}} align 256
+; CHECK: ret void
+
+
define void @LongDoubleTest(x86_fp80* nocapture %a) nounwind uwtable sanitize_address {
entry:
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %a, align 16