[ASan] Minor fixes to dynamic allocas handling:
[oota-llvm.git] / test / Instrumentation / AddressSanitizer / debug_info_noninstrumented_alloca.ll
1 ; This test checks that non-instrumented allocas stay in the first basic block.
2 ; Only first-basic-block allocas are considered stack slots, and moving them
3 ; breaks debug info.
4
5 ; RUN: opt < %s -asan -asan-module -S | FileCheck %s
6 ; RUN: opt < %s -asan -asan-module -asan-instrument-allocas=1 -S | FileCheck %s
7
8 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-apple-macosx10.10.0"
10
11 define i32 @foo() sanitize_address {
12 entry:
13   ; Won't be instrumented because of asan-skip-promotable-allocas.
14   %non_instrumented1 = alloca i32, align 4
15
16   ; Regular alloca, will get instrumented (forced by the ptrtoint below).
17   %instrumented = alloca i32, align 4
18
19   ; Won't be instrumented because of asan-skip-promotable-allocas.
20   %non_instrumented2 = alloca i32, align 4
21
22   br label %bb0
23
24 bb0:
25   ; Won't be instrumented because of asan-skip-promotable-allocas.
26   %non_instrumented3 = alloca i32, align 4
27
28   %ptr = ptrtoint i32* %instrumented to i32
29   br label %bb1
30
31 bb1:
32   ret i32 %ptr
33 }
34
35 ; CHECK: entry:
36 ; CHECK: %non_instrumented1 = alloca i32, align 4
37 ; CHECK: %non_instrumented2 = alloca i32, align 4
38 ; CHECK: load i32, i32* @__asan_option_detect_stack_use_after_return
39 ; CHECK: bb0:
40 ; CHECK: %non_instrumented3 = alloca i32, align 4