summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2015-07-17 06:29:57 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2015-07-17 06:29:57 +0000
commit37a5ffaca0ddf95a56da0deead8e01aa943a0aaf (patch)
treee025b092bf3750d4cf8d4746b90ee4530978ea05 /llvm/test
parent810329490aac73dccabab9aecdb50fade5e10a4f (diff)
downloadbcm5719-llvm-37a5ffaca0ddf95a56da0deead8e01aa943a0aaf.tar.gz
bcm5719-llvm-37a5ffaca0ddf95a56da0deead8e01aa943a0aaf.zip
[asan] Fix invalid debug info for promotable allocas
Since r230724 ("Skip promotable allocas to improve performance at -O0"), there is a regression in the generated debug info for those non-instrumented variables. When inspecting such a variable's value in LLDB, you often get garbage instead of the actual value. ASan instrumentation is inserted before the creation of the non-instrumented alloca. The only allocas that are considered standard stack variables are the ones declared in the first basic-block, but the initial instrumentation setup in the function breaks that invariant. This patch makes sure uninstrumented allocas stay in the first BB. Differential Revision: http://reviews.llvm.org/D11179 llvm-svn: 242510
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Instrumentation/AddressSanitizer/debug_info_noninstrumented_alloca.ll26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/test/Instrumentation/AddressSanitizer/debug_info_noninstrumented_alloca.ll b/llvm/test/Instrumentation/AddressSanitizer/debug_info_noninstrumented_alloca.ll
new file mode 100644
index 00000000000..7c38729ff43
--- /dev/null
+++ b/llvm/test/Instrumentation/AddressSanitizer/debug_info_noninstrumented_alloca.ll
@@ -0,0 +1,26 @@
+; This test checks that non-instrumented allocas stay in the first basic block.
+; Only first-basic-block allocas are considered stack slots, and moving them
+; breaks debug info.
+
+; RUN: opt < %s -asan -asan-module -S | FileCheck %s
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.10.0"
+
+define i32 @foo() sanitize_address {
+entry:
+ ; Regular alloca, will get instrumented (forced by the ptrtoint below).
+ %instrumented = alloca i32, align 4
+
+ ; Won't be instrumented because of asan-skip-promotable-allocas.
+ %non_instrumented = alloca i32, align 4
+ store i32 0, i32* %non_instrumented, align 4
+ %value = load i32, i32* %non_instrumented, align 4
+
+ %ptr = ptrtoint i32* %instrumented to i64
+ ret i32 %value
+}
+
+; CHECK: entry:
+; CHECK: %non_instrumented = alloca i32, align 4
+; CHECK: load i32, i32* @__asan_option_detect_stack_use_after_return
OpenPOWER on IntegriCloud