diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2015-11-05 21:18:41 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2015-11-05 21:18:41 +0000 |
commit | 55fda1be94c9d72e9d1239ee0e1c74e38253eb82 (patch) | |
tree | 26ae08f3177ef60276959d4dccf14133ceb4aace | |
parent | db73c2f54c3ee974a662a6c196f38f73e6c3d42d (diff) | |
download | bcm5719-llvm-55fda1be94c9d72e9d1239ee0e1c74e38253eb82.tar.gz bcm5719-llvm-55fda1be94c9d72e9d1239ee0e1c74e38253eb82.zip |
[ASan] Disable instrumentation for inalloca variables.
inalloca variables were not treated as static allocas, therefore didn't
participate in regular stack instrumentation. We don't want them to
participate in dynamic alloca instrumentation as well.
llvm-svn: 252213
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 5 | ||||
-rw-r--r-- | llvm/test/Instrumentation/AddressSanitizer/instrument-dynamic-allocas.ll | 16 |
2 files changed, 20 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 538cc850295..1c51264d737 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -840,7 +840,10 @@ bool AddressSanitizer::isInterestingAlloca(AllocaInst &AI) { getAllocaSizeInBytes(&AI) > 0 && // We are only interested in allocas not promotable to registers. // Promotable allocas are common under -O0. - (!ClSkipPromotableAllocas || !isAllocaPromotable(&AI))); + (!ClSkipPromotableAllocas || !isAllocaPromotable(&AI)) && + // inalloca allocas are not treated as static, and we don't want + // dynamic alloca instrumentation for them as well. + !AI.isUsedWithInAlloca()); ProcessedAllocas[&AI] = IsInteresting; return IsInteresting; diff --git a/llvm/test/Instrumentation/AddressSanitizer/instrument-dynamic-allocas.ll b/llvm/test/Instrumentation/AddressSanitizer/instrument-dynamic-allocas.ll index ceaf0e6fcfb..f6354b1ee59 100644 --- a/llvm/test/Instrumentation/AddressSanitizer/instrument-dynamic-allocas.ll +++ b/llvm/test/Instrumentation/AddressSanitizer/instrument-dynamic-allocas.ll @@ -7,8 +7,10 @@ target triple = "x86_64-unknown-linux-gnu" define void @foo(i32 %len) sanitize_address { entry: +; CHECK-ALLOCA-LABEL: define void @foo ; CHECK-ALLOCA: __asan_alloca_poison ; CHECK-ALLOCA: __asan_allocas_unpoison +; CHECK-ALLOCA: ret void %0 = alloca i32, align 4 %1 = alloca i8* store volatile i32 %len, i32* %0, align 4 @@ -19,3 +21,17 @@ entry: ret void } +; Test that dynamic alloca is not used for inalloca variables. +define void @has_inalloca() uwtable sanitize_address { +; CHECK-ALLOCA-LABEL: define void @has_inalloca +; CHECK-ALLOCA-NOT: __asan_alloca_poison +; CHECK-ALLOCA-NOT: __asan_alloca_unpoison +; CHECK-ALLOCA: ret void +entry: + %t = alloca inalloca i32 + store i32 42, i32* %t + call void @pass_inalloca(i32* inalloca %t) + ret void +} + +declare void @pass_inalloca(i32* inalloca) |