xref: /llvm-project/llvm/test/Instrumentation/AddressSanitizer/alloca-offset-lifetime.ll (revision 855fe35064674c4601ea9c659a015cacdcec9f63)
1; Test that ASAN will not instrument lifetime markers on alloca offsets.
2;
3; RUN: opt < %s -passes=asan --asan-use-after-scope -S | FileCheck %s
4
5target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-apple-macosx10.15.0"
7
8%t = type { ptr, ptr, %sub, i64 }
9%sub = type { i32 }
10
11define void @foo() sanitize_address {
12entry:
13  %0 = alloca %t, align 8
14  %x = getelementptr inbounds %t, ptr %0, i64 0, i32 2
15  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x)
16  call void @bar(ptr nonnull %x)
17  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #3
18  ret void
19}
20
21declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
22declare void @bar(ptr)
23declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
24
25; CHECK: store i64 %[[STACK_BASE:.+]], ptr %asan_local_stack_base, align 8
26; CHECK-NOT: store i8 0
27; CHECK: call void @bar(ptr nonnull %x)
28