1 ; RUN: opt < %s -passes=asan -asan-use-after-return=never -S | FileCheck --check-prefix=CHECK-PLAIN --implicit-check-not=__asan_stack_malloc %s
2 ; RUN: opt < %s -passes=asan -asan-use-after-return=runtime -S | FileCheck --check-prefixes=CHECK-UAR,CHECK-UAR-RUNTIME %s
3 ; RUN: opt < %s -passes=asan -asan-use-after-return=always -S | FileCheck --check-prefixes=CHECK-UAR,CHECK-UAR-ALWAYS %s
4 target datalayout = "e-i64:64-f80:128-s:64-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
9 define void @Bar() uwtable sanitize_address {
11 ; CHECK-PLAIN-LABEL: Bar
12 ; CHECK-PLAIN-NOT: label
13 ; CHECK-PLAIN: ret void
15 ; CHECK-UAR-LABEL: Bar
16 ; CHECK-UAR-RUNTIME: load i32, ptr @__asan_option_detect_stack_use_after_return
17 ; CHECK-UAR-RUNTIME: label
18 ; CHECK-UAR-RUNTIME: call i64 @__asan_stack_malloc_4
19 ; CHECK-UAR-ALWAYS: call i64 @__asan_stack_malloc_always_4
20 ; CHECK-UAR-RUNTIME: label
22 ; CHECK-UAR: store i64 -1007680412564983311
23 ; CHECK-UAR: store i64 72057598113936114
24 ; CHECK-UAR: store i32 -218959118
25 ; CHECK-UAR: store i64 -868082074056920316
26 ; CHECK-UAR: store i16 -3085
27 ; CHECK-UAR: call void @Foo
28 ; CHECK-UAR: call void @Foo
29 ; CHECK-UAR: call void @Foo
30 ; If LocalStackBase != OrigStackBase
32 ; Then Block: poison the entire frame.
33 ; CHECK-UAR: call void @__asan_set_shadow_f5(i64 %{{[0-9]+}}, i64 128)
34 ; CHECK-UAR-NOT: store i64
36 ; Else Block: no UAR frame. Only unpoison the redzones.
37 ; CHECK-UAR: store i64 0
38 ; CHECK-UAR: store i64 0
39 ; CHECK-UAR: store i32 0
40 ; CHECK-UAR: store i64 0
41 ; CHECK-UAR: store i16 0
42 ; CHECK-UAR-NOT: store
44 ; Done, no more stores.
45 ; CHECK-UAR-NOT: store
48 %x = alloca [20 x i8], align 16
49 %y = alloca [25 x i8], align 1
50 %z = alloca [500 x i8], align 1
51 call void @Foo(ptr %x)
52 call void @Foo(ptr %y)
53 call void @Foo(ptr %z)