diff options
Diffstat (limited to 'test/Instrumentation')
27 files changed, 431 insertions, 103 deletions
diff --git a/test/Instrumentation/AddressSanitizer/freebsd.ll b/test/Instrumentation/AddressSanitizer/freebsd.ll index 5178432d63aa8..f940b52b41f31 100644 --- a/test/Instrumentation/AddressSanitizer/freebsd.ll +++ b/test/Instrumentation/AddressSanitizer/freebsd.ll @@ -1,11 +1,11 @@ ; RUN: opt < %s -asan -asan-module -S \ ; RUN: -mtriple=i386-unknown-freebsd \ -; RUN: -default-data-layout="e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" | \ +; RUN: -data-layout="e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" | \ ; RUN: FileCheck --check-prefix=CHECK-32 %s ; RUN: opt < %s -asan -asan-module -S \ ; RUN: -mtriple=x86_64-unknown-freebsd \ -; RUN: -default-data-layout="e-m:e-i64:64-f80:128-n8:16:32:64-S128" | \ +; RUN: -data-layout="e-m:e-i64:64-f80:128-n8:16:32:64-S128" | \ ; RUN: FileCheck --check-prefix=CHECK-64 %s define i32 @read_4_bytes(i32* %a) sanitize_address { diff --git a/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll b/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll index 686b506a96c47..27cbd61ef81fa 100644 --- a/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll +++ b/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll @@ -13,7 +13,7 @@ $mystr = comdat any ; CHECK: $dead_global = comdat noduplicates ; CHECK: @dead_global = local_unnamed_addr global { i32, [60 x i8] } { i32 42, [60 x i8] zeroinitializer }, comdat, align 32 -; CHECK: @__asan_global_dead_global = internal global { {{.*}} }, section ".ASAN$GL", comdat($dead_global), align 64 +; CHECK: @__asan_global_dead_global = private global { {{.*}} }, section ".ASAN$GL", comdat($dead_global), align 64 @dead_global = local_unnamed_addr global i32 42, align 4 @mystr = linkonce_odr unnamed_addr constant [5 x i8] c"main\00", comdat, align 1 diff --git a/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll b/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll index 01a7a6610cafa..8341697ff48c9 100644 --- a/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll +++ b/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll @@ -16,10 +16,10 @@ entry: ; OPT1: IncrementMe ; OPT1: __asan_report_ ; OPT1-NOT: __asan_report_ -; OPT1: asan.module_ctor +; OPT1: ret void ; Without optimizations we should see two calls to __asan_report_* ; OPT0: IncrementMe ; OPT0: __asan_report_ ; OPT0: __asan_report_ -; OPT0: asan.module_ctor +; OPT0: ret void diff --git a/test/Instrumentation/AddressSanitizer/lifetime-throw.ll b/test/Instrumentation/AddressSanitizer/lifetime-throw.ll index 6d0cbd9ad5aac..ff03d10c7c5d7 100644 --- a/test/Instrumentation/AddressSanitizer/lifetime-throw.ll +++ b/test/Instrumentation/AddressSanitizer/lifetime-throw.ll @@ -23,7 +23,7 @@ entry: ; Poison memory in prologue: F1F1F1F1F8F3F3F3 ; CHECK: store i64 -868082052615769615, i64* %{{[0-9]+}} - call void @llvm.lifetime.start(i64 4, i8* %0) + call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) ; CHECK: store i8 4, i8* %{{[0-9]+}} ; CHECK-NEXT: @llvm.lifetime.start @@ -37,7 +37,7 @@ lpad: %1 = landingpad { i8*, i32 } cleanup call void @_ZN3ABCD2Ev(%struct.ABC* nonnull %x) - call void @llvm.lifetime.end(i64 4, i8* %0) + call void @llvm.lifetime.end.p0i8(i64 4, i8* %0) ; CHECK: store i8 -8, i8* %{{[0-9]+}} ; CHECK-NEXT: @llvm.lifetime.end @@ -77,7 +77,7 @@ entry: ; Poison memory in prologue: F1F1F1F1F8F304F2 ; CHECK: store i64 -935355671561244175, i64* %{{[0-9]+}} - call void @llvm.lifetime.start(i64 4, i8* %0) + call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) ; CHECK: store i8 4, i8* %{{[0-9]+}} ; CHECK-NEXT: @llvm.lifetime.start @@ -90,7 +90,7 @@ entry: ehcleanup: %2 = cleanuppad within none [] call void @"\01??1ABC@@QEAA@XZ"(%struct.ABC* nonnull %x) [ "funclet"(token %2) ] - call void @llvm.lifetime.end(i64 4, i8* %0) + call void @llvm.lifetime.end.p0i8(i64 4, i8* %0) ; CHECK: store i8 -8, i8* %{{[0-9]+}} ; CHECK-NEXT: @llvm.lifetime.end @@ -104,8 +104,8 @@ unreachable: declare i32 @__gxx_personality_v0(...) -declare void @llvm.lifetime.start(i64, i8* nocapture) -declare void @llvm.lifetime.end(i64, i8* nocapture) +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) declare void @__cxa_throw(i8*, i8*, i8*) local_unnamed_addr declare i8* @__cxa_allocate_exception(i64) local_unnamed_addr declare void @_ZN3ABCD2Ev(%struct.ABC* %this) unnamed_addr diff --git a/test/Instrumentation/AddressSanitizer/lifetime-uar-uas.ll b/test/Instrumentation/AddressSanitizer/lifetime-uar-uas.ll index 93708e350fa38..437b6a94185b8 100644 --- a/test/Instrumentation/AddressSanitizer/lifetime-uar-uas.ll +++ b/test/Instrumentation/AddressSanitizer/lifetime-uar-uas.ll @@ -6,8 +6,8 @@ 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" -declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind -declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) nounwind define i32 @basic_test() sanitize_address { ; CHECK-LABEL: define i32 @basic_test() @@ -19,14 +19,14 @@ entry: ; Memory is poisoned in prologue: F1F1F1F104F3F8F2 ; CHECK-UAS: store i64 -866676825215864335, i64* %{{[0-9]+}} - call void @llvm.lifetime.start(i64 1, i8* %c) + call void @llvm.lifetime.start.p0i8(i64 1, i8* %c) ; Memory is unpoisoned at llvm.lifetime.start: 01 ; CHECK-UAS: store i8 1, i8* %{{[0-9]+}} store volatile i32 0, i32* %retval store volatile i8 0, i8* %c, align 1 - call void @llvm.lifetime.end(i64 1, i8* %c) + call void @llvm.lifetime.end.p0i8(i64 1, i8* %c) ; Memory is poisoned at llvm.lifetime.end: F8 ; CHECK-UAS: store i8 -8, i8* %{{[0-9]+}} diff --git a/test/Instrumentation/AddressSanitizer/lifetime.ll b/test/Instrumentation/AddressSanitizer/lifetime.ll index be72124f3ab62..b951afdc670f1 100644 --- a/test/Instrumentation/AddressSanitizer/lifetime.ll +++ b/test/Instrumentation/AddressSanitizer/lifetime.ll @@ -5,8 +5,8 @@ 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" target triple = "x86_64-unknown-linux-gnu" -declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind -declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) nounwind define void @lifetime_no_size() sanitize_address { ; CHECK-LABEL: define void @lifetime_no_size() @@ -17,7 +17,7 @@ entry: ; Poison memory in prologue: F1F1F1F104F3F3F3 ; CHECK: store i64 -868083100587789839, i64* %{{[0-9]+}} - call void @llvm.lifetime.start(i64 -1, i8* %i.ptr) + call void @llvm.lifetime.start.p0i8(i64 -1, i8* %i.ptr) ; Check that lifetime with no size are ignored. ; CHECK-NOT: store ; CHECK: call void @llvm.lifetime.start @@ -25,7 +25,7 @@ entry: store volatile i8 0, i8* %i.ptr ; CHECK: store volatile - call void @llvm.lifetime.end(i64 -1, i8* %i.ptr) + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %i.ptr) ; Check that lifetime with no size are ignored. ; CHECK-NOT: store ; CHECK: call void @llvm.lifetime.end @@ -48,19 +48,19 @@ define void @lifetime() sanitize_address { ; CHECK: store i64 -868082052615769615, i64* %{{[0-9]+}} ; Memory is unpoisoned at llvm.lifetime.start - call void @llvm.lifetime.start(i64 3, i8* %i.ptr) + call void @llvm.lifetime.start.p0i8(i64 3, i8* %i.ptr) ; CHECK: store i8 4, i8* %{{[0-9]+}} ; CHECK-NEXT: llvm.lifetime.start store volatile i8 0, i8* %i.ptr ; CHECK: store volatile - call void @llvm.lifetime.end(i64 4, i8* %i.ptr) + call void @llvm.lifetime.end.p0i8(i64 4, i8* %i.ptr) ; CHECK: store i8 -8, i8* %{{[0-9]+}} ; CHECK-NEXT: call void @llvm.lifetime.end ; Memory is poisoned at every call to llvm.lifetime.end - call void @llvm.lifetime.end(i64 2, i8* %i.ptr) + call void @llvm.lifetime.end.p0i8(i64 2, i8* %i.ptr) ; CHECK: store i8 -8, i8* %{{[0-9]+}} ; CHECK-NEXT: call void @llvm.lifetime.end @@ -68,26 +68,26 @@ define void @lifetime() sanitize_address { %arr = alloca [10 x i32], align 16 %arr.ptr = bitcast [10 x i32]* %arr to i8* - call void @llvm.lifetime.start(i64 40, i8* %arr.ptr) + call void @llvm.lifetime.start.p0i8(i64 40, i8* %arr.ptr) ; CHECK-DEFAULT: call void @__asan_unpoison_stack_memory(i64 %{{[^ ]+}}, i64 40) ; CHECK-NO-DYNAMIC-NOT: call void @__asan_unpoison_stack_memory(i64 %{{[^ ]+}}, i64 40) store volatile i8 0, i8* %arr.ptr ; CHECK: store volatile - call void @llvm.lifetime.end(i64 40, i8* %arr.ptr) + call void @llvm.lifetime.end.p0i8(i64 40, i8* %arr.ptr) ; CHECK-DEFAULT: call void @__asan_poison_stack_memory(i64 %{{[^ ]+}}, i64 40) ; CHECK-NO-DYNAMIC-NOT: call void @__asan_poison_stack_memory(i64 %{{[^ ]+}}, i64 40) ; One more lifetime start/end for the same variable %i. - call void @llvm.lifetime.start(i64 2, i8* %i.ptr) + call void @llvm.lifetime.start.p0i8(i64 2, i8* %i.ptr) ; CHECK: store i8 4, i8* %{{[0-9]+}} ; CHECK-NEXT: llvm.lifetime.start store volatile i8 0, i8* %i.ptr ; CHECK: store volatile - call void @llvm.lifetime.end(i64 4, i8* %i.ptr) + call void @llvm.lifetime.end.p0i8(i64 4, i8* %i.ptr) ; CHECK: store i8 -8, i8* %{{[0-9]+}} ; CHECK-NEXT: llvm.lifetime.end @@ -108,7 +108,7 @@ entry: ; Poison memory in prologue: F1F1F1F1F8F3F3F3 ; CHECK: store i64 -868082052615769615, i64* %{{[0-9]+}} - call void @llvm.lifetime.start(i64 8, i8* %i.ptr) + call void @llvm.lifetime.start.p0i8(i64 8, i8* %i.ptr) ; CHECK: store i8 0, i8* %{{[0-9]+}} ; CHECK-NEXT: llvm.lifetime.start @@ -123,7 +123,7 @@ bb0: bb1: %i.phi = phi i8* [ %i.ptr, %entry ], [ %i.ptr2, %bb0 ] - call void @llvm.lifetime.end(i64 8, i8* %i.phi) + call void @llvm.lifetime.end.p0i8(i64 8, i8* %i.phi) ; CHECK: store i8 -8, i8* %{{[0-9]+}} ; CHECK-NEXT: llvm.lifetime.end @@ -147,14 +147,14 @@ entry: ; CHECK: store i64 -868082074056920077, i64* %{{[0-9]+}} %0 = getelementptr inbounds [1024 x i8], [1024 x i8]* %x, i64 0, i64 0 - call void @llvm.lifetime.start(i64 1024, i8* %0) + call void @llvm.lifetime.start.p0i8(i64 1024, i8* %0) ; CHECK: call void @__asan_set_shadow_00(i64 %{{[0-9]+}}, i64 128) ; CHECK-NEXT: call void @llvm.lifetime.start store i8* %0, i8** %d, align 8 ; CHECK: store i8 - call void @llvm.lifetime.end(i64 1024, i8* %0) + call void @llvm.lifetime.end.p0i8(i64 1024, i8* %0) ; CHECK: call void @__asan_set_shadow_f8(i64 %{{[0-9]+}}, i64 128) ; CHECK-NEXT: call void @llvm.lifetime.end @@ -172,12 +172,12 @@ entry: store i64 %a, i64* %a.addr, align 8 %0 = bitcast [0 x i8]* %b to i8* - call void @llvm.lifetime.start(i64 0, i8* %0) #2 + call void @llvm.lifetime.start.p0i8(i64 0, i8* %0) #2 ; CHECK: %{{[0-9]+}} = bitcast ; CHECK-NEXT: call void @llvm.lifetime.start %1 = bitcast [0 x i8]* %b to i8* - call void @llvm.lifetime.end(i64 0, i8* %1) #2 + call void @llvm.lifetime.end.p0i8(i64 0, i8* %1) #2 ; CHECK-NEXT: %{{[0-9]+}} = bitcast ; CHECK-NEXT: call void @llvm.lifetime.end diff --git a/test/Instrumentation/AddressSanitizer/ps4.ll b/test/Instrumentation/AddressSanitizer/ps4.ll new file mode 100644 index 0000000000000..e160996866b4f --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/ps4.ll @@ -0,0 +1,14 @@ +; RUN: opt < %s -asan -asan-module -S -mtriple=x86_64-scei-ps4 | FileCheck %s + +define i32 @read_4_bytes(i32* %a) sanitize_address { +entry: + %tmp1 = load i32, i32* %a, align 4 + ret i32 %tmp1 +} + +; CHECK: @read_4_bytes +; CHECK-NOT: ret +; Check for ASAN's Offset on the PS4 (2^40 or 0x10000000000) +; CHECK: lshr {{.*}} 3 +; CHECK-NEXT: {{1099511627776}} +; CHECK: ret diff --git a/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime-be.ll b/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime-be.ll index 059c49a3457cc..569a67d6d3567 100644 --- a/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime-be.ll +++ b/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime-be.ll @@ -91,7 +91,7 @@ entry: ; CHECK-NEXT: %zz = getelementptr inbounds - call void @llvm.lifetime.start(i64 650, i8* %xx) + call void @llvm.lifetime.start.p0i8(i64 650, i8* %xx) ; 0000... ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 4 ; ENTRY-UAS-NEXT: call void @__asan_set_shadow_00(i64 [[OFFSET]], i64 81) @@ -100,39 +100,39 @@ entry: ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i8]]* ; ENTRY-UAS-NEXT: store [[TYPE]] 2, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.start(i64 650, i8* %xx) + ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 650, i8* %xx) call void @Foo(i8* %xx) ; CHECK-NEXT: call void @Foo(i8* %xx) - call void @llvm.lifetime.end(i64 650, i8* %xx) + call void @llvm.lifetime.end.p0i8(i64 650, i8* %xx) ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 4 ; ENTRY-UAS-NEXT: call void @__asan_set_shadow_f8(i64 [[OFFSET]], i64 82) - ; CHECK-NEXT: call void @llvm.lifetime.end(i64 650, i8* %xx) + ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 650, i8* %xx) - call void @llvm.lifetime.start(i64 13, i8* %yy) + call void @llvm.lifetime.start.p0i8(i64 13, i8* %yy) ; 0005 ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 102 ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i16]]* ; ENTRY-UAS-NEXT: store [[TYPE]] 5, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.start(i64 13, i8* %yy) + ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 13, i8* %yy) call void @Foo(i8* %yy) ; CHECK-NEXT: call void @Foo(i8* %yy) - call void @llvm.lifetime.end(i64 13, i8* %yy) + call void @llvm.lifetime.end.p0i8(i64 13, i8* %yy) ; F8F8 ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 102 ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i16]]* ; ENTRY-UAS-NEXT: store [[TYPE]] -1800, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.end(i64 13, i8* %yy) + ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 13, i8* %yy) - call void @llvm.lifetime.start(i64 40, i8* %zz) + call void @llvm.lifetime.start.p0i8(i64 40, i8* %zz) ; 00000000 ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 106 ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i32]]* @@ -142,12 +142,12 @@ entry: ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i8]]* ; ENTRY-UAS-NEXT: store [[TYPE]] 0, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.start(i64 40, i8* %zz) + ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 40, i8* %zz) call void @Foo(i8* %zz) ; CHECK-NEXT: call void @Foo(i8* %zz) - call void @llvm.lifetime.end(i64 40, i8* %zz) + call void @llvm.lifetime.end.p0i8(i64 40, i8* %zz) ; F8F8F8F8 ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 106 ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i32]]* @@ -157,7 +157,7 @@ entry: ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i8]]* ; ENTRY-UAS-NEXT: store [[TYPE]] -8, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.end(i64 40, i8* %zz) + ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 40, i8* %zz) ; CHECK-LABEL: <label> @@ -209,8 +209,8 @@ entry: ; CHECK: ret void } -declare void @llvm.lifetime.start(i64, i8* nocapture) -declare void @llvm.lifetime.end(i64, i8* nocapture) +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) ; CHECK-ON: declare void @__asan_set_shadow_00(i64, i64) ; CHECK-ON: declare void @__asan_set_shadow_f1(i64, i64) diff --git a/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime.ll b/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime.ll index 48d3b0e53ccbf..0799b03e455ea 100644 --- a/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime.ll +++ b/test/Instrumentation/AddressSanitizer/stack-poisoning-and-lifetime.ll @@ -91,7 +91,7 @@ entry: ; CHECK-NEXT: %zz = getelementptr inbounds - call void @llvm.lifetime.start(i64 650, i8* %xx) + call void @llvm.lifetime.start.p0i8(i64 650, i8* %xx) ; 0000... ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 4 ; ENTRY-UAS-NEXT: call void @__asan_set_shadow_00(i64 [[OFFSET]], i64 81) @@ -100,39 +100,39 @@ entry: ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i8]]* ; ENTRY-UAS-NEXT: store [[TYPE]] 2, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.start(i64 650, i8* %xx) + ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 650, i8* %xx) call void @Foo(i8* %xx) ; CHECK-NEXT: call void @Foo(i8* %xx) - call void @llvm.lifetime.end(i64 650, i8* %xx) + call void @llvm.lifetime.end.p0i8(i64 650, i8* %xx) ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 4 ; ENTRY-UAS-NEXT: call void @__asan_set_shadow_f8(i64 [[OFFSET]], i64 82) - ; CHECK-NEXT: call void @llvm.lifetime.end(i64 650, i8* %xx) + ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 650, i8* %xx) - call void @llvm.lifetime.start(i64 13, i8* %yy) + call void @llvm.lifetime.start.p0i8(i64 13, i8* %yy) ; 0005 ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 102 ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i16]]* ; ENTRY-UAS-NEXT: store [[TYPE]] 1280, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.start(i64 13, i8* %yy) + ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 13, i8* %yy) call void @Foo(i8* %yy) ; CHECK-NEXT: call void @Foo(i8* %yy) - call void @llvm.lifetime.end(i64 13, i8* %yy) + call void @llvm.lifetime.end.p0i8(i64 13, i8* %yy) ; F8F8 ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 102 ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i16]]* ; ENTRY-UAS-NEXT: store [[TYPE]] -1800, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.end(i64 13, i8* %yy) + ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 13, i8* %yy) - call void @llvm.lifetime.start(i64 40, i8* %zz) + call void @llvm.lifetime.start.p0i8(i64 40, i8* %zz) ; 00000000 ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 106 ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i32]]* @@ -142,12 +142,12 @@ entry: ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i8]]* ; ENTRY-UAS-NEXT: store [[TYPE]] 0, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.start(i64 40, i8* %zz) + ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 40, i8* %zz) call void @Foo(i8* %zz) ; CHECK-NEXT: call void @Foo(i8* %zz) - call void @llvm.lifetime.end(i64 40, i8* %zz) + call void @llvm.lifetime.end.p0i8(i64 40, i8* %zz) ; F8F8F8F8 ; ENTRY-UAS-NEXT: [[OFFSET:%[0-9]+]] = add i64 [[SHADOW_BASE]], 106 ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i32]]* @@ -157,7 +157,7 @@ entry: ; ENTRY-UAS-NEXT: [[PTR:%[0-9]+]] = inttoptr i64 [[OFFSET]] to [[TYPE:i8]]* ; ENTRY-UAS-NEXT: store [[TYPE]] -8, [[TYPE]]* [[PTR]], align 1 - ; CHECK-NEXT: call void @llvm.lifetime.end(i64 40, i8* %zz) + ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 40, i8* %zz) ; CHECK-LABEL: <label> @@ -209,8 +209,8 @@ entry: ; CHECK: ret void } -declare void @llvm.lifetime.start(i64, i8* nocapture) -declare void @llvm.lifetime.end(i64, i8* nocapture) +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) ; CHECK-ON: declare void @__asan_set_shadow_00(i64, i64) ; CHECK-ON: declare void @__asan_set_shadow_f1(i64, i64) diff --git a/test/Instrumentation/AddressSanitizer/stack_layout.ll b/test/Instrumentation/AddressSanitizer/stack_layout.ll index 96706f70c83b8..4e756f9ab2f25 100644 --- a/test/Instrumentation/AddressSanitizer/stack_layout.ll +++ b/test/Instrumentation/AddressSanitizer/stack_layout.ll @@ -9,8 +9,8 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 target triple = "x86_64-unknown-linux-gnu" declare void @Use(i8*) -declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind -declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) nounwind ; CHECK: private unnamed_addr constant{{.*}}3 32 10 3 XXX 64 20 3 YYY 128 30 3 ZZZ\0 ; CHECK: private unnamed_addr constant{{.*}}3 32 5 3 AAA 64 55 3 BBB 160 555 3 CCC\0 @@ -87,13 +87,13 @@ define void @Func5() sanitize_address #0 !dbg !11 { %AAA = alloca i32, align 4 ; File is not the same as !11 %BBB = alloca i32, align 4 ; File is the same as !11 %BBB.ptr = bitcast i32* %BBB to i8* - call void @llvm.lifetime.start(i64 4, i8* nonnull %BBB.ptr), !dbg !12 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %BBB.ptr), !dbg !12 store volatile i32 5, i32* %BBB, align 4 %AAA.ptr = bitcast i32* %AAA to i8* - call void @llvm.lifetime.start(i64 4, i8* nonnull %AAA.ptr), !dbg !14 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %AAA.ptr), !dbg !14 store volatile i32 3, i32* %AAA, align 4 - call void @llvm.lifetime.end(i64 4, i8* nonnull %AAA.ptr), !dbg !17 - call void @llvm.lifetime.end(i64 4, i8* nonnull %BBB.ptr), !dbg !18 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %AAA.ptr), !dbg !17 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %BBB.ptr), !dbg !18 ret void } diff --git a/test/Instrumentation/InstrProfiling/PR23499.ll b/test/Instrumentation/InstrProfiling/PR23499.ll index 47c60fd802ab1..101fad19950e6 100644 --- a/test/Instrumentation/InstrProfiling/PR23499.ll +++ b/test/Instrumentation/InstrProfiling/PR23499.ll @@ -13,15 +13,15 @@ $_Z3barIvEvv = comdat any @__profn__Z3barIvEvv = linkonce_odr hidden constant [11 x i8] c"_Z3barIvEvv", align 1 -; CHECK: @__profn__Z3barIvEvv = private constant [11 x i8] c"_Z3barIvEvv", align 1 +; CHECK-NOT: __profn__Z3barIvEvv ; CHECK: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat($__profv__Z3barIvEvv), align 8 -; CHECK: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [1 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data{{.*}}", comdat($__profv__Z3barIvEvv), align 8 +; CHECK: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [2 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [2 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data{{.*}}", comdat($__profv__Z3barIvEvv), align 8 ; CHECK: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names" -; COFF: @__profn__Z3barIvEvv = private constant [11 x i8] c"_Z3barIvEvv", align 1 -; COFF: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat, align 8 -; COFF: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [1 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data{{.*}}", comdat($__profc__Z3barIvEvv), align 8 +; COFF-NOT: __profn__Z3barIvEvv +; COFF: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}prfc", comdat, align 8 +; COFF: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [2 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [2 x i16] zeroinitializer }, section "{{.*}}prfd{{.*}}", comdat($__profc__Z3barIvEvv), align 8 declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #1 diff --git a/test/Instrumentation/InstrProfiling/icall.ll b/test/Instrumentation/InstrProfiling/icall.ll index 529ad9ce12f05..d92de47421d40 100644 --- a/test/Instrumentation/InstrProfiling/icall.ll +++ b/test/Instrumentation/InstrProfiling/icall.ll @@ -37,9 +37,9 @@ attributes #0 = { nounwind } ; DYN-NOT: @__profvp_foo ; DYN-NOT: @__llvm_prf_vnodes -; STATIC: call void @__llvm_profile_instrument_target(i64 %3, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [1 x i16] }* @__profd_foo to i8*), i32 0) -; STATIC-EXT: call void @__llvm_profile_instrument_target(i64 %3, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [1 x i16] }* @__profd_foo to i8*), i32 zeroext 0) -; STATIC-SEXT: call void @__llvm_profile_instrument_target(i64 %3, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [1 x i16] }* @__profd_foo to i8*), i32 signext 0) +; STATIC: call void @__llvm_profile_instrument_target(i64 %3, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [2 x i16] }* @__profd_foo to i8*), i32 0) +; STATIC-EXT: call void @__llvm_profile_instrument_target(i64 %3, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [2 x i16] }* @__profd_foo to i8*), i32 zeroext 0) +; STATIC-SEXT: call void @__llvm_profile_instrument_target(i64 %3, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [2 x i16] }* @__profd_foo to i8*), i32 signext 0) ; STATIC: declare void @__llvm_profile_instrument_target(i64, i8*, i32) ; STATIC-EXT: declare void @__llvm_profile_instrument_target(i64, i8*, i32 zeroext) diff --git a/test/Instrumentation/InstrProfiling/platform.ll b/test/Instrumentation/InstrProfiling/platform.ll index b731fc3e5ff5e..c0c711054ff1a 100644 --- a/test/Instrumentation/InstrProfiling/platform.ll +++ b/test/Instrumentation/InstrProfiling/platform.ll @@ -12,8 +12,8 @@ ; RUN: opt < %s -mtriple=x86_64-pc-solaris -passes=instrprof -S | FileCheck %s -check-prefix=SOLARIS @__profn_foo = hidden constant [3 x i8] c"foo" -; MACHO: @__profn_foo = private constant [3 x i8] c"foo" -; ELF: @__profn_foo = private constant [3 x i8] c"foo" +; MACHO-NOT: __profn_foo +; ELF-NOT: __profn_foo ; MACHO: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 ; ELF: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8 diff --git a/test/Instrumentation/InstrProfiling/profiling.ll b/test/Instrumentation/InstrProfiling/profiling.ll index 508d3ef8dea00..c4cc1d9ce4387 100644 --- a/test/Instrumentation/InstrProfiling/profiling.ll +++ b/test/Instrumentation/InstrProfiling/profiling.ll @@ -4,11 +4,11 @@ target triple = "x86_64-apple-macosx10.10.0" @__profn_foo = hidden constant [3 x i8] c"foo" -; CHECK: @__profn_foo = private constant [3 x i8] c"foo" +; CHECK-NOT: __profn_foo @__profn_bar = hidden constant [4 x i8] c"bar\00" -; CHECK: @__profn_bar = private constant [4 x i8] c"bar\00" +; CHECK-NOT: __profn_bar @__profn_baz = hidden constant [3 x i8] c"baz" -; CHECK: @__profn_baz = private constant [3 x i8] c"baz" +; CHECK-NOT: __profn_baz ; CHECK: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 ; CHECK: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8 diff --git a/test/Instrumentation/MemorySanitizer/AArch64/vararg.ll b/test/Instrumentation/MemorySanitizer/AArch64/vararg.ll index 99b4604562394..18d2c3bfe4d83 100644 --- a/test/Instrumentation/MemorySanitizer/AArch64/vararg.ll +++ b/test/Instrumentation/MemorySanitizer/AArch64/vararg.ll @@ -8,10 +8,10 @@ target triple = "aarch64-unknown-linux-gnu" define i32 @foo(i32 %guard, ...) { %vl = alloca %struct.__va_list, align 8 %1 = bitcast %struct.__va_list* %vl to i8* - call void @llvm.lifetime.start(i64 32, i8* %1) + call void @llvm.lifetime.start.p0i8(i64 32, i8* %1) call void @llvm.va_start(i8* %1) call void @llvm.va_end(i8* %1) - call void @llvm.lifetime.end(i64 32, i8* %1) + call void @llvm.lifetime.end.p0i8(i64 32, i8* %1) ret i32 0 } @@ -46,10 +46,10 @@ define i32 @foo(i32 %guard, ...) { ; CHECK: [[STACK:%.*]] = getelementptr inbounds i8, i8* {{%.*}}, i32 192 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{%.*}}, i8* [[STACK]], i64 {{%.*}}, i32 16, i1 false) -declare void @llvm.lifetime.start(i64, i8* nocapture) #1 +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1 declare void @llvm.va_start(i8*) #2 declare void @llvm.va_end(i8*) #2 -declare void @llvm.lifetime.end(i64, i8* nocapture) #1 +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1 define i32 @bar() { %1 = call i32 (i32, ...) @foo(i32 0, i32 1, i32 2, double 3.000000e+00, diff --git a/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64.ll b/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64.ll index 71397f1db5a44..46e840c607f97 100644 --- a/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64.ll +++ b/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64.ll @@ -6,10 +6,10 @@ target triple = "mips64--linux" define i32 @foo(i32 %guard, ...) { %vl = alloca i8*, align 8 %1 = bitcast i8** %vl to i8* - call void @llvm.lifetime.start(i64 32, i8* %1) + call void @llvm.lifetime.start.p0i8(i64 32, i8* %1) call void @llvm.va_start(i8* %1) call void @llvm.va_end(i8* %1) - call void @llvm.lifetime.end(i64 32, i8* %1) + call void @llvm.lifetime.end.p0i8(i64 32, i8* %1) ret i32 0 } @@ -23,10 +23,10 @@ define i32 @foo(i32 %guard, ...) { ; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8* ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[C]], i8* [[STACK]], i64 [[B]], i32 8, i1 false) -declare void @llvm.lifetime.start(i64, i8* nocapture) #1 +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1 declare void @llvm.va_start(i8*) #2 declare void @llvm.va_end(i8*) #2 -declare void @llvm.lifetime.end(i64, i8* nocapture) #1 +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1 define i32 @bar() { %1 = call i32 (i32, ...) @foo(i32 0, i32 1, i64 2, double 3.000000e+00) diff --git a/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64el.ll b/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64el.ll index 9931b13baacb2..e0177b63d68d5 100644 --- a/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64el.ll +++ b/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64el.ll @@ -6,10 +6,10 @@ target triple = "mips64el--linux" define i32 @foo(i32 %guard, ...) { %vl = alloca i8*, align 8 %1 = bitcast i8** %vl to i8* - call void @llvm.lifetime.start(i64 32, i8* %1) + call void @llvm.lifetime.start.p0i8(i64 32, i8* %1) call void @llvm.va_start(i8* %1) call void @llvm.va_end(i8* %1) - call void @llvm.lifetime.end(i64 32, i8* %1) + call void @llvm.lifetime.end.p0i8(i64 32, i8* %1) ret i32 0 } @@ -23,10 +23,10 @@ define i32 @foo(i32 %guard, ...) { ; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8* ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[C]], i8* [[STACK]], i64 [[B]], i32 8, i1 false) -declare void @llvm.lifetime.start(i64, i8* nocapture) #1 +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1 declare void @llvm.va_start(i8*) #2 declare void @llvm.va_end(i8*) #2 -declare void @llvm.lifetime.end(i64, i8* nocapture) #1 +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1 define i32 @bar() { %1 = call i32 (i32, ...) @foo(i32 0, i32 1, i64 2, double 3.000000e+00) diff --git a/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64.ll b/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64.ll index 71f4b3466595d..afc4b775de352 100644 --- a/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64.ll +++ b/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64.ll @@ -6,10 +6,10 @@ target triple = "powerpc64--linux" define i32 @foo(i32 %guard, ...) { %vl = alloca i8*, align 8 %1 = bitcast i8** %vl to i8* - call void @llvm.lifetime.start(i64 32, i8* %1) + call void @llvm.lifetime.start.p0i8(i64 32, i8* %1) call void @llvm.va_start(i8* %1) call void @llvm.va_end(i8* %1) - call void @llvm.lifetime.end(i64 32, i8* %1) + call void @llvm.lifetime.end.p0i8(i64 32, i8* %1) ret i32 0 } @@ -23,10 +23,10 @@ define i32 @foo(i32 %guard, ...) { ; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8* ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[C]], i8* [[STACK]], i64 [[B]], i32 8, i1 false) -declare void @llvm.lifetime.start(i64, i8* nocapture) #1 +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1 declare void @llvm.va_start(i8*) #2 declare void @llvm.va_end(i8*) #2 -declare void @llvm.lifetime.end(i64, i8* nocapture) #1 +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1 define i32 @bar() { %1 = call i32 (i32, ...) @foo(i32 0, i32 1, i64 2, double 3.000000e+00) diff --git a/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64le.ll b/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64le.ll index 6e844dce54912..1afe778ad79a5 100644 --- a/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64le.ll +++ b/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64le.ll @@ -6,10 +6,10 @@ target triple = "powerpc64le--linux" define i32 @foo(i32 %guard, ...) { %vl = alloca i8*, align 8 %1 = bitcast i8** %vl to i8* - call void @llvm.lifetime.start(i64 32, i8* %1) + call void @llvm.lifetime.start.p0i8(i64 32, i8* %1) call void @llvm.va_start(i8* %1) call void @llvm.va_end(i8* %1) - call void @llvm.lifetime.end(i64 32, i8* %1) + call void @llvm.lifetime.end.p0i8(i64 32, i8* %1) ret i32 0 } @@ -23,10 +23,10 @@ define i32 @foo(i32 %guard, ...) { ; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8* ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[C]], i8* [[STACK]], i64 [[B]], i32 8, i1 false) -declare void @llvm.lifetime.start(i64, i8* nocapture) #1 +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1 declare void @llvm.va_start(i8*) #2 declare void @llvm.va_end(i8*) #2 -declare void @llvm.lifetime.end(i64, i8* nocapture) #1 +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1 define i32 @bar() { %1 = call i32 (i32, ...) @foo(i32 0, i32 1, i64 2, double 3.000000e+00) diff --git a/test/Instrumentation/MemorySanitizer/alloca.ll b/test/Instrumentation/MemorySanitizer/alloca.ll new file mode 100644 index 0000000000000..57ee9120ae831 --- /dev/null +++ b/test/Instrumentation/MemorySanitizer/alloca.ll @@ -0,0 +1,59 @@ +; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s --check-prefixes=CHECK,INLINE +; RUN: opt < %s -msan -msan-check-access-address=0 -msan-poison-stack-with-call=1 -S | FileCheck %s --check-prefixes=CHECK,CALL +; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck %s --check-prefixes=CHECK,ORIGIN +; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck %s --check-prefixes=CHECK,ORIGIN + +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" +target triple = "x86_64-unknown-linux-gnu" + +define void @static() sanitize_memory { +entry: + %x = alloca i32, align 4 + ret void +} + +; CHECK-LABEL: define void @static( +; INLINE: call void @llvm.memset.p0i8.i64(i8* {{.*}}, i8 -1, i64 4, i32 4, i1 false) +; CALL: call void @__msan_poison_stack(i8* {{.*}}, i64 4) +; ORIGIN: call void @__msan_set_alloca_origin4(i8* {{.*}}, i64 4, +; CHECK: ret void + + +define void @dynamic() sanitize_memory { +entry: + br label %l +l: + %x = alloca i32, align 4 + ret void +} + +; CHECK-LABEL: define void @dynamic( +; INLINE: call void @llvm.memset.p0i8.i64(i8* {{.*}}, i8 -1, i64 4, i32 4, i1 false) +; CALL: call void @__msan_poison_stack(i8* {{.*}}, i64 4) +; ORIGIN: call void @__msan_set_alloca_origin4(i8* {{.*}}, i64 4, +; CHECK: ret void + +define void @array() sanitize_memory { +entry: + %x = alloca i32, i64 5, align 4 + ret void +} + +; CHECK-LABEL: define void @array( +; INLINE: call void @llvm.memset.p0i8.i64(i8* {{.*}}, i8 -1, i64 20, i32 4, i1 false) +; CALL: call void @__msan_poison_stack(i8* {{.*}}, i64 20) +; ORIGIN: call void @__msan_set_alloca_origin4(i8* {{.*}}, i64 20, +; CHECK: ret void + +define void @array_non_const(i64 %cnt) sanitize_memory { +entry: + %x = alloca i32, i64 %cnt, align 4 + ret void +} + +; CHECK-LABEL: define void @array_non_const( +; CHECK: %[[A:.*]] = mul i64 4, %cnt +; INLINE: call void @llvm.memset.p0i8.i64(i8* {{.*}}, i8 -1, i64 %[[A]], i32 4, i1 false) +; CALL: call void @__msan_poison_stack(i8* {{.*}}, i64 %[[A]]) +; ORIGIN: call void @__msan_set_alloca_origin4(i8* {{.*}}, i64 %[[A]], +; CHECK: ret void diff --git a/test/Instrumentation/MemorySanitizer/csr.ll b/test/Instrumentation/MemorySanitizer/csr.ll new file mode 100644 index 0000000000000..c4e3a3f739200 --- /dev/null +++ b/test/Instrumentation/MemorySanitizer/csr.ll @@ -0,0 +1,52 @@ +; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s +; RUN: opt < %s -msan -msan-check-access-address=1 -S | FileCheck %s --check-prefix=ADDR + +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" +target triple = "x86_64-unknown-linux-gnu" + +declare void @llvm.x86.sse.stmxcsr(i8*) +declare void @llvm.x86.sse.ldmxcsr(i8*) + +define void @getcsr(i32 *%p) sanitize_memory { +entry: + %0 = bitcast i32* %p to i8* + call void @llvm.x86.sse.stmxcsr(i8* %0) + ret void +} + +; CHECK-LABEL: @getcsr( +; CHECK: store i32 0, i32* +; CHECK: call void @llvm.x86.sse.stmxcsr( +; CHECK: ret void + +; ADDR-LABEL: @getcsr( +; ADDR: %[[A:.*]] = load i64, i64* getelementptr inbounds {{.*}} @__msan_param_tls, i32 0, i32 0), align 8 +; ADDR: %[[B:.*]] = icmp ne i64 %[[A]], 0 +; ADDR: br i1 %[[B]], label {{.*}}, label +; ADDR: call void @__msan_warning_noreturn() +; ADDR: call void @llvm.x86.sse.stmxcsr( +; ADDR: ret void + +; Function Attrs: nounwind uwtable +define void @setcsr(i32 *%p) sanitize_memory { +entry: + %0 = bitcast i32* %p to i8* + call void @llvm.x86.sse.ldmxcsr(i8* %0) + ret void +} + +; CHECK-LABEL: @setcsr( +; CHECK: %[[A:.*]] = load i32, i32* %{{.*}}, align 1 +; CHECK: %[[B:.*]] = icmp ne i32 %[[A]], 0 +; CHECK: br i1 %[[B]], label {{.*}}, label +; CHECK: call void @__msan_warning_noreturn() +; CHECK: call void @llvm.x86.sse.ldmxcsr( +; CHECK: ret void + +; ADDR-LABEL: @setcsr( +; ADDR: %[[A:.*]] = load i64, i64* getelementptr inbounds {{.*}} @__msan_param_tls, i32 0, i32 0), align 8 +; ADDR: %[[B:.*]] = icmp ne i64 %[[A]], 0 +; ADDR: br i1 %[[B]], label {{.*}}, label +; ADDR: call void @__msan_warning_noreturn() +; ADDR: call void @llvm.x86.sse.ldmxcsr( +; ADDR: ret void diff --git a/test/Instrumentation/SanitizerCoverage/coverage.ll b/test/Instrumentation/SanitizerCoverage/coverage.ll index a2a92a02c7180..75a341da021c9 100644 --- a/test/Instrumentation/SanitizerCoverage/coverage.ll +++ b/test/Instrumentation/SanitizerCoverage/coverage.ll @@ -1,13 +1,12 @@ ; RUN: opt < %s -sancov -sanitizer-coverage-level=0 -S | FileCheck %s --check-prefix=CHECK0 ; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -S | FileCheck %s --check-prefix=CHECK1 -; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -S | FileCheck %s --check-prefix=CHECK2 +; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -S | FileCheck %s --check-prefix=CHECK_WITH_CHECK ; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=10 -S | FileCheck %s --check-prefix=CHECK2 ; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=0 -S | FileCheck %s --check-prefix=CHECK_WITH_CHECK ; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=1 -S | FileCheck %s --check-prefix=CHECK_WITH_CHECK ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-block-threshold=10 -S | FileCheck %s --check-prefix=CHECK3 ; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -S | FileCheck %s --check-prefix=CHECK4 ; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK_TRACE_PC -; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_TRACE_PC ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-8bit-counters=1 -S | FileCheck %s --check-prefix=CHECK-8BIT ; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=10 \ diff --git a/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll b/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll index 37eca1065fdc2..fde1904259d5f 100644 --- a/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll +++ b/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll @@ -17,8 +17,8 @@ target triple = "x86_64-unknown-linux-gnu" ; Check that __sanitizer_cov call has !dgb pointing to the beginning ; of appropriate basic blocks. ; CHECK-LABEL:_Z3fooPi -; CHECK: call void @__sanitizer_cov(i32*{{.*}}), !dbg [[A:!.*]] -; CHECK: call void @__sanitizer_cov(i32*{{.*}}), !dbg [[B:!.*]] +; CHECK: call void @__sanitizer_cov{{.*}}(i32*{{.*}}), !dbg [[A:!.*]] +; CHECK: call void @__sanitizer_cov{{.*}}(i32*{{.*}}), !dbg [[B:!.*]] ; CHECK: ret void ; CHECK: [[A]] = !DILocation(line: 1, scope: !{{.*}}) ; CHECK: [[B]] = !DILocation(line: 3, column: 5, scope: !{{.*}}) diff --git a/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll b/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll new file mode 100644 index 0000000000000..8ab5f4961b1b5 --- /dev/null +++ b/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll @@ -0,0 +1,42 @@ +; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_TRACE_PC_GUARD + +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" +target triple = "x86_64-unknown-linux-gnu" +define void @foo(i32* %a) sanitize_address { +entry: + %tobool = icmp eq i32* %a, null + br i1 %tobool, label %if.end, label %if.then + + if.then: ; preds = %entry + store i32 0, i32* %a, align 4 + br label %if.end + + if.end: ; preds = %entry, %if.then + ret void +} + +%struct.StructWithVptr = type { i32 (...)** } + +define void @CallViaVptr(%struct.StructWithVptr* %foo) uwtable sanitize_address { +entry: + %0 = bitcast %struct.StructWithVptr* %foo to void (%struct.StructWithVptr*)*** + %vtable = load void (%struct.StructWithVptr*)**, void (%struct.StructWithVptr*)*** %0, align 8 + %1 = load void (%struct.StructWithVptr*)*, void (%struct.StructWithVptr*)** %vtable, align 8 + tail call void %1(%struct.StructWithVptr* %foo) + tail call void %1(%struct.StructWithVptr* %foo) + tail call void asm sideeffect "", ""() + ret void +} + +; CHECK_TRACE_PC_GUARD-LABEL: define void @foo +; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc +; CHECK_TRACE_PC_GUARD: call void asm sideeffect "", ""() +; CHECK_TRACE_PC_GUARD: ret void + +; CHECK_TRACE_PC_GUARD-LABEL: define void @CallViaVptr +; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc_indir +; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc_indir +; CHECK_TRACE_PC_GUARD: ret void + +; CHECK_TRACE_PC_GUARD-LABEL: define internal void @sancov.module_ctor() comdat + diff --git a/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll b/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll new file mode 100644 index 0000000000000..392ff8d293270 --- /dev/null +++ b/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll @@ -0,0 +1,42 @@ +; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_TRACE_PC_GUARD + +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" +target triple = "x86_64-apple-darwin10.0.0" +define void @foo(i32* %a) sanitize_address { +entry: + %tobool = icmp eq i32* %a, null + br i1 %tobool, label %if.end, label %if.then + + if.then: ; preds = %entry + store i32 0, i32* %a, align 4 + br label %if.end + + if.end: ; preds = %entry, %if.then + ret void +} + +%struct.StructWithVptr = type { i32 (...)** } + +define void @CallViaVptr(%struct.StructWithVptr* %foo) uwtable sanitize_address { +entry: + %0 = bitcast %struct.StructWithVptr* %foo to void (%struct.StructWithVptr*)*** + %vtable = load void (%struct.StructWithVptr*)**, void (%struct.StructWithVptr*)*** %0, align 8 + %1 = load void (%struct.StructWithVptr*)*, void (%struct.StructWithVptr*)** %vtable, align 8 + tail call void %1(%struct.StructWithVptr* %foo) + tail call void %1(%struct.StructWithVptr* %foo) + tail call void asm sideeffect "", ""() + ret void +} + +; CHECK_TRACE_PC_GUARD-LABEL: define void @foo +; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc +; CHECK_TRACE_PC_GUARD: call void asm sideeffect "", ""() +; CHECK_TRACE_PC_GUARD: ret void + +; CHECK_TRACE_PC_GUARD-LABEL: define void @CallViaVptr +; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc_indir +; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc_indir +; CHECK_TRACE_PC_GUARD: ret void + +; CHECK_TRACE_PC_GUARD-LABEL: define internal void @sancov.module_ctor() { + diff --git a/test/Instrumentation/SanitizerCoverage/tracing.ll b/test/Instrumentation/SanitizerCoverage/tracing.ll index 49c2a1a635273..9e153472eaba2 100644 --- a/test/Instrumentation/SanitizerCoverage/tracing.ll +++ b/test/Instrumentation/SanitizerCoverage/tracing.ll @@ -3,6 +3,7 @@ ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-experimental-tracing -S | FileCheck %s --check-prefix=CHECK3 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK_PC ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_PC_GUARD +; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S -mtriple=x86_64-apple-macosx | FileCheck %s --check-prefix=CHECK_PC_GUARD_DARWIN 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" target triple = "x86_64-unknown-linux-gnu" @@ -47,3 +48,11 @@ entry: ; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc ; CHECK_PC_GUARD: ret void ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard_init(i32* bitcast (i32** @__start___sancov_guards to i32*), i32* bitcast (i32** @__stop___sancov_guards to i32*)) + +; CHECK_PC_GUARD_DARWIN-LABEL: define void @foo +; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard +; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard +; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard +; CHECK_PC_GUARD_DARWIN-NOT: call void @__sanitizer_cov_trace_pc +; CHECK_PC_GUARD_DARWIN: ret void +; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard_init(i32* bitcast (i32** @"\01section$start$__DATA$__sancov_guards" to i32*), i32* bitcast (i32** @"\01section$end$__DATA$__sancov_guards" to i32*)) diff --git a/test/Instrumentation/SanitizerCoverage/wineh.ll b/test/Instrumentation/SanitizerCoverage/wineh.ll new file mode 100644 index 0000000000000..87b44be5544f3 --- /dev/null +++ b/test/Instrumentation/SanitizerCoverage/wineh.ll @@ -0,0 +1,111 @@ +; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK + +; Generated from this C++ source: +; $ clang -O2 t.cpp -S -emit-llvm +; void g(); +; struct Foo { Foo(); ~Foo(); }; +; int f() { +; Foo v; +; g(); +; try { +; g(); +; } catch (int e) { +; g(); +; } catch (...) { +; g(); +; } +; return 0; +; } + +; FIXME: We need to do more than this. In particular, __sanitizer_cov callbacks +; in funclets need token bundles. + +; CHECK-LABEL: define i32 @"\01?f@@YAHXZ"() +; CHECK: catch.dispatch: +; CHECK-NEXT: catchswitch within none [label %catch3, label %catch] unwind label %ehcleanup + +; ModuleID = 't.cpp' +source_filename = "t.cpp" +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.10.24728" + +%rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] } +%struct.Foo = type { i8 } + +$"\01??_R0H@8" = comdat any + +@"\01??_7type_info@@6B@" = external constant i8* +@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat + +; Function Attrs: uwtable +define i32 @"\01?f@@YAHXZ"() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { +entry: + %v = alloca %struct.Foo, align 1 + %e = alloca i32, align 4 + %0 = getelementptr inbounds %struct.Foo, %struct.Foo* %v, i64 0, i32 0 + call void @llvm.lifetime.start(i64 1, i8* nonnull %0) #4 + %call = call %struct.Foo* @"\01??0Foo@@QEAA@XZ"(%struct.Foo* nonnull %v) + invoke void @"\01?g@@YAXXZ"() + to label %invoke.cont unwind label %ehcleanup + +invoke.cont: ; preds = %entry + invoke void @"\01?g@@YAXXZ"() + to label %try.cont unwind label %catch.dispatch + +catch.dispatch: ; preds = %invoke.cont + %1 = catchswitch within none [label %catch3, label %catch] unwind label %ehcleanup + +catch3: ; preds = %catch.dispatch + %2 = catchpad within %1 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i32* %e] + invoke void @"\01?g@@YAXXZ"() [ "funclet"(token %2) ] + to label %invoke.cont4 unwind label %ehcleanup + +invoke.cont4: ; preds = %catch3 + catchret from %2 to label %try.cont + +try.cont: ; preds = %invoke.cont, %invoke.cont2, %invoke.cont4 + call void @"\01??1Foo@@QEAA@XZ"(%struct.Foo* nonnull %v) #4 + call void @llvm.lifetime.end(i64 1, i8* nonnull %0) #4 + ret i32 0 + +catch: ; preds = %catch.dispatch + %3 = catchpad within %1 [i8* null, i32 64, i8* null] + invoke void @"\01?g@@YAXXZ"() [ "funclet"(token %3) ] + to label %invoke.cont2 unwind label %ehcleanup + +invoke.cont2: ; preds = %catch + catchret from %3 to label %try.cont + +ehcleanup: ; preds = %catch3, %catch, %catch.dispatch, %entry + %4 = cleanuppad within none [] + call void @"\01??1Foo@@QEAA@XZ"(%struct.Foo* nonnull %v) #4 [ "funclet"(token %4) ] + call void @llvm.lifetime.end(i64 1, i8* nonnull %0) #4 + cleanupret from %4 unwind to caller +} + +; Function Attrs: argmemonly nounwind +declare void @llvm.lifetime.start(i64, i8* nocapture) #1 + +declare %struct.Foo* @"\01??0Foo@@QEAA@XZ"(%struct.Foo* returned) unnamed_addr #2 + +declare void @"\01?g@@YAXXZ"() local_unnamed_addr #2 + +declare i32 @__CxxFrameHandler3(...) + +; Function Attrs: nounwind +declare void @"\01??1Foo@@QEAA@XZ"(%struct.Foo*) unnamed_addr #3 + +; Function Attrs: argmemonly nounwind +declare void @llvm.lifetime.end(i64, i8* nocapture) #1 + +attributes #0 = { uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { argmemonly nounwind } +attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #3 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #4 = { nounwind } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"PIC Level", i32 2} +!1 = !{!"clang version 5.0.0 "} |