1 ; Test handling of llvm.lifetime intrinsics in UAR/UAS modes.
2 ; RUN: opt < %s -passes=asan -asan-use-after-return=never -asan-use-after-scope=0 -S | FileCheck %s
3 ; RUN: opt < %s -passes=asan -asan-use-after-return=runtime -asan-use-after-scope=0 -S | FileCheck %s
4 ; RUN: opt < %s -passes=asan -asan-use-after-return=always -asan-use-after-scope=0 -S | FileCheck %s
5 ; RUN: opt < %s -passes=asan -asan-use-after-return=never -asan-use-after-scope=1 -S | FileCheck %s --check-prefix=CHECK-UAS
6 ; RUN: opt < %s -passes=asan -asan-use-after-return=runtime -asan-use-after-scope=1 -S | FileCheck %s --check-prefix=CHECK-UAS
7 ; RUN: opt < %s -passes=asan -asan-use-after-return=always -asan-use-after-scope=1 -S | FileCheck %s --check-prefix=CHECK-UAS
9 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
11 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) nounwind
12 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) nounwind
14 define i32 @basic_test(i64 %i) sanitize_address {
15 ; CHECK-LABEL: define i32 @basic_test(
18 %retval = alloca i32, align 4
19 %c = alloca [2 x i8], align 1
21 ; Memory is poisoned in prologue: F1F1F1F104F3F8F2
22 ; CHECK-UAS: store i64 -866676825215864335, ptr %{{[0-9]+}}
23 ; CHECK-UAS-SS-NOT: store i64
25 call void @llvm.lifetime.start.p0(i64 1, ptr %c)
26 ; Memory is unpoisoned at llvm.lifetime.start: 01
27 ; CHECK-UAS: store i8 2, ptr %{{[0-9]+}}
29 %ci = getelementptr inbounds [2 x i8], ptr %c, i64 0, i64 %i
30 store volatile i32 0, ptr %retval
31 store volatile i8 0, ptr %ci, align 1
33 call void @llvm.lifetime.end.p0(i64 1, ptr %c)
34 ; Memory is poisoned at llvm.lifetime.end: F8
35 ; CHECK-UAS: store i8 -8, ptr %{{[0-9]+}}
36 ; CHECK-UAS-SS-NOT: store i8 -8,
38 ; Unpoison memory at function exit in UAS mode.
39 ; CHECK-UAS: store i64 0, ptr %{{[0-9]+}}
40 ; CHECK-UAS: ret i32 0
44 ; No poisoning/poisoning at all in plain mode.
45 ; CHECK-NOT: __asan_poison_stack_memory
46 ; CHECK-NOT: __asan_unpoison_stack_memory