diff options
Diffstat (limited to 'test/Instrumentation/AddressSanitizer')
12 files changed, 269 insertions, 28 deletions
diff --git a/test/Instrumentation/AddressSanitizer/X86/bug_11395.ll b/test/Instrumentation/AddressSanitizer/X86/bug_11395.ll index 35c5c4a0bb..38168fc2d6 100644 --- a/test/Instrumentation/AddressSanitizer/X86/bug_11395.ll +++ b/test/Instrumentation/AddressSanitizer/X86/bug_11395.ll @@ -36,14 +36,14 @@ target triple = "i386-unknown-linux-gnu" @ff_mlp_firorder_7 = external global i8 @ff_mlp_firorder_8 = external global i8 -define void @ff_mlp_init_x86(%struct.DSPContext* nocapture %c, %struct.AVCodecContext* nocapture %avctx) nounwind address_safety { +define void @ff_mlp_init_x86(%struct.DSPContext* nocapture %c, %struct.AVCodecContext* nocapture %avctx) nounwind sanitize_address { entry: %mlp_filter_channel = getelementptr inbounds %struct.DSPContext* %c, i32 0, i32 131 store void (i32*, i32*, i32, i32, i32, i32, i32, i32*)* @mlp_filter_channel_x86, void (i32*, i32*, i32, i32, i32, i32, i32, i32*)** %mlp_filter_channel, align 4, !tbaa !0 ret void } -define internal void @mlp_filter_channel_x86(i32* %state, i32* %coeff, i32 %firorder, i32 %iirorder, i32 %filter_shift, i32 %mask, i32 %blocksize, i32* %sample_buffer) nounwind address_safety { +define internal void @mlp_filter_channel_x86(i32* %state, i32* %coeff, i32 %firorder, i32 %iirorder, i32 %filter_shift, i32 %mask, i32 %blocksize, i32* %sample_buffer) nounwind sanitize_address { entry: %filter_shift.addr = alloca i32, align 4 %mask.addr = alloca i32, align 4 diff --git a/test/Instrumentation/AddressSanitizer/adaptive_global_redzones.ll b/test/Instrumentation/AddressSanitizer/adaptive_global_redzones.ll new file mode 100644 index 0000000000..6a60d1c29f --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/adaptive_global_redzones.ll @@ -0,0 +1,57 @@ +; RUN: opt < %s -asan -asan-module -S | FileCheck %s +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" + +; Here we check that the global redzone sizes grow with the object size. + +@G10 = global [10 x i8] zeroinitializer, align 1 +; CHECK: @G10 = global { [10 x i8], [54 x i8] } + +@G31 = global [31 x i8] zeroinitializer, align 1 +@G32 = global [32 x i8] zeroinitializer, align 1 +@G33 = global [33 x i8] zeroinitializer, align 1 +; CHECK: @G31 = global { [31 x i8], [33 x i8] } +; CHECK: @G32 = global { [32 x i8], [32 x i8] } +; CHECK: @G33 = global { [33 x i8], [63 x i8] } + +@G63 = global [63 x i8] zeroinitializer, align 1 +@G64 = global [64 x i8] zeroinitializer, align 1 +@G65 = global [65 x i8] zeroinitializer, align 1 +; CHECK: @G63 = global { [63 x i8], [33 x i8] } +; CHECK: @G64 = global { [64 x i8], [32 x i8] } +; CHECK: @G65 = global { [65 x i8], [63 x i8] } + +@G127 = global [127 x i8] zeroinitializer, align 1 +@G128 = global [128 x i8] zeroinitializer, align 1 +@G129 = global [129 x i8] zeroinitializer, align 1 +; CHECK: @G127 = global { [127 x i8], [33 x i8] } +; CHECK: @G128 = global { [128 x i8], [32 x i8] } +; CHECK: @G129 = global { [129 x i8], [63 x i8] } + +@G255 = global [255 x i8] zeroinitializer, align 1 +@G256 = global [256 x i8] zeroinitializer, align 1 +@G257 = global [257 x i8] zeroinitializer, align 1 +; CHECK: @G255 = global { [255 x i8], [33 x i8] } +; CHECK: @G256 = global { [256 x i8], [64 x i8] } +; CHECK: @G257 = global { [257 x i8], [95 x i8] } + +@G511 = global [511 x i8] zeroinitializer, align 1 +@G512 = global [512 x i8] zeroinitializer, align 1 +@G513 = global [513 x i8] zeroinitializer, align 1 +; CHECK: @G511 = global { [511 x i8], [97 x i8] } +; CHECK: @G512 = global { [512 x i8], [128 x i8] } +; CHECK: @G513 = global { [513 x i8], [159 x i8] } + +@G1023 = global [1023 x i8] zeroinitializer, align 1 +@G1024 = global [1024 x i8] zeroinitializer, align 1 +@G1025 = global [1025 x i8] zeroinitializer, align 1 +; CHECK: @G1023 = global { [1023 x i8], [225 x i8] } +; CHECK: @G1024 = global { [1024 x i8], [256 x i8] } +; CHECK: @G1025 = global { [1025 x i8], [287 x i8] } + +@G1000000 = global [1000000 x i8] zeroinitializer, align 1 +@G10000000 = global [10000000 x i8] zeroinitializer, align 1 +@G100000000 = global [100000000 x i8] zeroinitializer, align 1 +; CHECK: @G1000000 = global { [1000000 x i8], [249984 x i8] } +; CHECK: @G10000000 = global { [10000000 x i8], [262144 x i8] } +; CHECK: @G100000000 = global { [100000000 x i8], [262144 x i8] } diff --git a/test/Instrumentation/AddressSanitizer/asan-vs-gvn.ll b/test/Instrumentation/AddressSanitizer/asan-vs-gvn.ll index c0fe15e9fc..da8f541375 100644 --- a/test/Instrumentation/AddressSanitizer/asan-vs-gvn.ll +++ b/test/Instrumentation/AddressSanitizer/asan-vs-gvn.ll @@ -11,9 +11,9 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3 @f = global %struct_of_7_bytes_4_aligned zeroinitializer, align 4 -; Accessing bytes 4 and 6, not ok to widen to i32 if address_safety is set. +; Accessing bytes 4 and 6, not ok to widen to i32 if sanitize_address is set. -define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone address_safety { +define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone sanitize_address { entry: %tmp = load i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4 %conv = zext i8 %tmp to i32 @@ -36,7 +36,7 @@ define void @end_test_widening_bad() { ;; Accessing bytes 4 and 5. Ok to widen to i16. -define i32 @test_widening_ok(i8* %P) nounwind ssp noredzone address_safety { +define i32 @test_widening_ok(i8* %P) nounwind ssp noredzone sanitize_address { entry: %tmp = load i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4 %conv = zext i8 %tmp to i32 diff --git a/test/Instrumentation/AddressSanitizer/basic.ll b/test/Instrumentation/AddressSanitizer/basic.ll index 655f69c16f..c477b19904 100644 --- a/test/Instrumentation/AddressSanitizer/basic.ll +++ b/test/Instrumentation/AddressSanitizer/basic.ll @@ -5,12 +5,12 @@ 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 i32 @test_load(i32* %a) address_safety { +define i32 @test_load(i32* %a) sanitize_address { ; CHECK: @test_load ; CHECK-NOT: load ; CHECK: %[[LOAD_ADDR:[^ ]*]] = ptrtoint i32* %a to i64 ; CHECK: lshr i64 %[[LOAD_ADDR]], 3 -; CHECK: or i64 +; CHECK: {{or|add}} ; CHECK: %[[LOAD_SHADOW_PTR:[^ ]*]] = inttoptr ; CHECK: %[[LOAD_SHADOW:[^ ]*]] = load i8* %[[LOAD_SHADOW_PTR]] ; CHECK: icmp ne i8 @@ -38,12 +38,12 @@ entry: ret i32 %tmp1 } -define void @test_store(i32* %a) address_safety { +define void @test_store(i32* %a) sanitize_address { ; CHECK: @test_store ; CHECK-NOT: store ; CHECK: %[[STORE_ADDR:[^ ]*]] = ptrtoint i32* %a to i64 ; CHECK: lshr i64 %[[STORE_ADDR]], 3 -; CHECK: or i64 +; CHECK: {{or|add}} ; CHECK: %[[STORE_SHADOW_PTR:[^ ]*]] = inttoptr ; CHECK: %[[STORE_SHADOW:[^ ]*]] = load i8* %[[STORE_SHADOW_PTR]] ; CHECK: icmp ne i8 @@ -73,7 +73,7 @@ entry: ; Check that asan leaves just one alloca. declare void @alloca_test_use([10 x i8]*) -define void @alloca_test() address_safety { +define void @alloca_test() sanitize_address { entry: %x = alloca [10 x i8], align 1 %y = alloca [10 x i8], align 1 @@ -89,3 +89,42 @@ entry: ; CHECK-NOT: = alloca ; CHECK: ret void +define void @LongDoubleTest(x86_fp80* nocapture %a) nounwind uwtable sanitize_address { +entry: + store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %a, align 16 + ret void +} + +; CHECK: LongDoubleTest +; CHECK: __asan_report_store_n +; CHECK: __asan_report_store_n +; CHECK: ret void + + +define void @i40test(i40* %a, i40* %b) nounwind uwtable sanitize_address { + entry: + %t = load i40* %a + store i40 %t, i40* %b, align 8 + ret void +} + +; CHECK: i40test +; CHECK: __asan_report_load_n{{.*}}, i64 5) +; CHECK: __asan_report_load_n{{.*}}, i64 5) +; CHECK: __asan_report_store_n{{.*}}, i64 5) +; CHECK: __asan_report_store_n{{.*}}, i64 5) +; CHECK: ret void + +define void @i80test(i80* %a, i80* %b) nounwind uwtable sanitize_address { + entry: + %t = load i80* %a + store i80 %t, i80* %b, align 8 + ret void +} + +; CHECK: i80test +; CHECK: __asan_report_load_n{{.*}}, i64 10) +; CHECK: __asan_report_load_n{{.*}}, i64 10) +; CHECK: __asan_report_store_n{{.*}}, i64 10) +; CHECK: __asan_report_store_n{{.*}}, i64 10) +; CHECK: ret void diff --git a/test/Instrumentation/AddressSanitizer/debug_info.ll b/test/Instrumentation/AddressSanitizer/debug_info.ll new file mode 100644 index 0000000000..7822fd06ab --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/debug_info.ll @@ -0,0 +1,60 @@ +; RUN: opt < %s -asan -asan-module -S | FileCheck %s + +; Checks that llvm.dbg.declare instructions are updated +; accordingly as we merge allocas. + +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 i32 @_Z3zzzi(i32 %p) nounwind uwtable sanitize_address { +entry: + %p.addr = alloca i32, align 4 + %r = alloca i32, align 4 + store i32 %p, i32* %p.addr, align 4 + call void @llvm.dbg.declare(metadata !{i32* %p.addr}, metadata !10), !dbg !11 + call void @llvm.dbg.declare(metadata !{i32* %r}, metadata !12), !dbg !14 + %0 = load i32* %p.addr, align 4, !dbg !14 + %add = add nsw i32 %0, 1, !dbg !14 + store i32 %add, i32* %r, align 4, !dbg !14 + %1 = load i32* %r, align 4, !dbg !15 + ret i32 %1, !dbg !15 +} + +; CHECK: define i32 @_Z3zzzi +; CHECK: entry: +; Verify that llvm.dbg.declare calls are in the entry basic block. +; CHECK-NOT: %entry +; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ARG_ID:[0-9]+]]) +; CHECK-NOT: %entry +; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[VAR_ID:[0-9]+]]) + +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, i32 0, i32 4, metadata !"a.cc", metadata !"/usr/local/google/llvm_cmake_clang/tmp/debuginfo", metadata !"clang version 3.3 (trunk 169314)", i1 true, i1 false, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !1} ; [ DW_TAG_compile_unit ] [/usr/local/google/llvm_cmake_clang/tmp/debuginfo/a.cc] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !2} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4} +!4 = metadata !{metadata !5} +!5 = metadata !{i32 786478, i32 0, metadata !6, metadata !"zzz", metadata !"zzz", metadata !"_Z3zzzi", metadata !6, i32 1, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z3zzzi, null, null, metadata !1, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [zzz] +!6 = metadata !{i32 786473, metadata !"a.cc", metadata !"/usr/local/google/llvm_cmake_clang/tmp/debuginfo", null} ; [ DW_TAG_file_type ] +!7 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!8 = metadata !{metadata !9, metadata !9} +!9 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!10 = metadata !{i32 786689, metadata !5, metadata !"p", metadata !6, i32 16777217, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [p] [line 1] +!11 = metadata !{i32 1, i32 0, metadata !5, null} +!12 = metadata !{i32 786688, metadata !13, metadata !"r", metadata !6, i32 2, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [r] [line 2] + +; Verify that debug descriptors for argument and local variable will be replaced +; with descriptors that end with OpDeref (encoded as 2). +; CHECK: ![[ARG_ID]] = metadata {{.*}} i64 2} ; [ DW_TAG_arg_variable ] [p] [line 1] +; CHECK: ![[VAR_ID]] = metadata {{.*}} i64 2} ; [ DW_TAG_auto_variable ] [r] [line 2] +; Verify that there are no more variable descriptors. +; CHECK-NOT: DW_TAG_arg_variable +; CHECK-NOT: DW_TAG_auto_variable + + +!13 = metadata !{i32 786443, metadata !5, i32 1, i32 0, metadata !6, i32 0} ; [ DW_TAG_lexical_block ] [/usr/local/google/llvm_cmake_clang/tmp/debuginfo/a.cc] +!14 = metadata !{i32 2, i32 0, metadata !13, null} +!15 = metadata !{i32 3, i32 0, metadata !13, null} diff --git a/test/Instrumentation/AddressSanitizer/different_scale_and_offset.ll b/test/Instrumentation/AddressSanitizer/different_scale_and_offset.ll new file mode 100644 index 0000000000..b0371769be --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/different_scale_and_offset.ll @@ -0,0 +1,41 @@ +; Test non-default shadow mapping scale and offset. +; +; RUN: opt < %s -asan -asan-mapping-scale=2 -asan-mapping-offset-log=0 -S | FileCheck %s + +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" + +; Test that ASan tells scale and offset to runtime. +; CHECK: @__asan_mapping_offset = linkonce_odr constant i64 0 +; CHECK: @__asan_mapping_scale = linkonce_odr constant i64 2 + +define i32 @test_load(i32* %a) sanitize_address { +; CHECK: @test_load +; CHECK-NOT: load +; CHECK: %[[LOAD_ADDR:[^ ]*]] = ptrtoint i32* %a to i64 +; CHECK: lshr i64 %[[LOAD_ADDR]], 2 + +; No need in shift for zero offset. +; CHECK-NOT: or i64 + +; CHECK: %[[LOAD_SHADOW_PTR:[^ ]*]] = inttoptr +; CHECK: %[[LOAD_SHADOW:[^ ]*]] = load i8* %[[LOAD_SHADOW_PTR]] +; CHECK: icmp ne i8 +; CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}} + +; No need in slow path for i32 and mapping scale equal to 2. +; CHECK-NOT: and i64 %[[LOAD_ADDR]] +; +; The crash block reports the error. +; CHECK: call void @__asan_report_load4(i64 %[[LOAD_ADDR]]) +; CHECK: unreachable +; +; The actual load. +; CHECK: %tmp1 = load i32* %a +; CHECK: ret i32 %tmp1 + +entry: + %tmp1 = load i32* %a + ret i32 %tmp1 +} + diff --git a/test/Instrumentation/AddressSanitizer/do-not-instrument-internal-globals.ll b/test/Instrumentation/AddressSanitizer/do-not-instrument-internal-globals.ll index 28d4ac0c0f..2efd6b1e0d 100644 --- a/test/Instrumentation/AddressSanitizer/do-not-instrument-internal-globals.ll +++ b/test/Instrumentation/AddressSanitizer/do-not-instrument-internal-globals.ll @@ -5,7 +5,7 @@ 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 @_Z3barv() uwtable address_safety { +define void @_Z3barv() uwtable sanitize_address { entry: %a = alloca i32, align 4 call void @_Z3fooPi(i32* %a) diff --git a/test/Instrumentation/AddressSanitizer/instrument-no-return.ll b/test/Instrumentation/AddressSanitizer/instrument-no-return.ll index e8f62b5485..2d835a3408 100644 --- a/test/Instrumentation/AddressSanitizer/instrument-no-return.ll +++ b/test/Instrumentation/AddressSanitizer/instrument-no-return.ll @@ -1,13 +1,13 @@ ; RUN: opt < %s -asan -S | FileCheck %s ; AddressSanitizer must insert __asan_handle_no_return -; before every noreturn call. +; before every noreturn call or invoke. 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" declare void @MyNoReturnFunc(i32) noreturn -define i32 @Call1(i8* nocapture %arg) uwtable address_safety { +define i32 @Call1(i8* nocapture %arg) uwtable sanitize_address { entry: call void @MyNoReturnFunc(i32 1) noreturn ; The call insn has noreturn attr. ; CHECK: @Call1 @@ -17,7 +17,7 @@ entry: unreachable } -define i32 @Call2(i8* nocapture %arg) uwtable address_safety { +define i32 @Call2(i8* nocapture %arg) uwtable sanitize_address { entry: call void @MyNoReturnFunc(i32 1) ; No noreturn attribure on the call. ; CHECK: @Call2 @@ -26,3 +26,24 @@ entry: ; CHECK-NEXT: unreachable unreachable } + +declare i32 @__gxx_personality_v0(...) + +define i64 @Invoke1(i8** %esc) nounwind uwtable ssp sanitize_address { +entry: + invoke void @MyNoReturnFunc(i32 1) + to label %invoke.cont unwind label %lpad + +invoke.cont: + ret i64 0 + +lpad: + %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer + ret i64 1 +} +; CHECK: @Invoke1 +; CHECK: call void @__asan_handle_no_return +; CHECK-NEXT: invoke void @MyNoReturnFunc +; CHECK: ret i64 0 +; CHECK: ret i64 1 diff --git a/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll b/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll index 042c06ba96..584db3762b 100644 --- a/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll +++ b/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll @@ -23,7 +23,7 @@ entry: ret void } -define internal void @_GLOBAL__I_a() address_safety section ".text.startup" { +define internal void @_GLOBAL__I_a() sanitize_address section ".text.startup" { entry: call void @__cxx_global_var_init() ret void @@ -40,7 +40,7 @@ entry: ; CHECK: ret ; Check that xxx is instrumented. -define void @touch_xxx() address_safety { +define void @touch_xxx() sanitize_address { store i32 0, i32 *@xxx, align 4 ret void ; CHECK: define void @touch_xxx @@ -49,7 +49,7 @@ define void @touch_xxx() address_safety { } ; Check that XXX is instrumented. -define void @touch_XXX() address_safety { +define void @touch_XXX() sanitize_address { store i32 0, i32 *@XXX, align 4 ret void ; CHECK: define void @touch_XXX @@ -59,7 +59,7 @@ define void @touch_XXX() address_safety { ; Check that yyy is NOT instrumented (as it does not have dynamic initializer). -define void @touch_yyy() address_safety { +define void @touch_yyy() sanitize_address { store i32 0, i32 *@yyy, align 4 ret void ; CHECK: define void @touch_yyy @@ -68,7 +68,7 @@ define void @touch_yyy() address_safety { } ; Check that YYY is NOT instrumented (as it does not have dynamic initializer). -define void @touch_YYY() address_safety { +define void @touch_YYY() sanitize_address { store i32 0, i32 *@YYY, align 4 ret void ; CHECK: define void @touch_YYY diff --git a/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll b/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll index 633bf9ae78..23cf6d28ec 100644 --- a/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll +++ b/test/Instrumentation/AddressSanitizer/instrument_load_then_store.ll @@ -4,7 +4,7 @@ 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 @IncrementMe(i32* %a) address_safety { +define void @IncrementMe(i32* %a) sanitize_address { entry: %tmp1 = load i32* %a, align 4 %tmp2 = add i32 %tmp1, 1 diff --git a/test/Instrumentation/AddressSanitizer/lifetime.ll b/test/Instrumentation/AddressSanitizer/lifetime.ll index 55cd475f1f..334872865f 100644 --- a/test/Instrumentation/AddressSanitizer/lifetime.ll +++ b/test/Instrumentation/AddressSanitizer/lifetime.ll @@ -7,7 +7,7 @@ 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 -define void @lifetime_no_size() address_safety { +define void @lifetime_no_size() sanitize_address { entry: %i = alloca i32, align 4 %i.ptr = bitcast i32* %i to i8* @@ -23,7 +23,7 @@ entry: } ; Generic case of lifetime analysis. -define void @lifetime() address_safety { +define void @lifetime() sanitize_address { ; CHECK: @lifetime ; Regular variable lifetime intrinsics. @@ -31,7 +31,7 @@ define void @lifetime() address_safety { %i.ptr = bitcast i32* %i to i8* call void @llvm.lifetime.start(i64 3, i8* %i.ptr) ; Memory is unpoisoned at llvm.lifetime.start - ; CHECK: %[[VAR:[^ ]*]] = ptrtoint i8* %i.ptr to i64 + ; CHECK: %[[VAR:[^ ]*]] = ptrtoint i32* %{{[^ ]+}} to i64 ; CHECK-NEXT: call void @__asan_unpoison_stack_memory(i64 %[[VAR]], i64 3) call void @llvm.lifetime.end(i64 4, i8* %i.ptr) call void @llvm.lifetime.end(i64 2, i8* %i.ptr) @@ -59,3 +59,26 @@ define void @lifetime() address_safety { ; CHECK: ret void ret void } + +; Check that arguments of lifetime may come from phi nodes. +define void @phi_args(i1 %x) sanitize_address { + ; CHECK: @phi_args + +entry: + %i = alloca i64, align 4 + %i.ptr = bitcast i64* %i to i8* + call void @llvm.lifetime.start(i64 8, i8* %i.ptr) + ; CHECK: __asan_unpoison_stack_memory + br i1 %x, label %bb0, label %bb1 + +bb0: + %i.ptr2 = bitcast i64* %i to i8* + br label %bb1 + +bb1: + %i.phi = phi i8* [ %i.ptr, %entry ], [ %i.ptr2, %bb0 ] + call void @llvm.lifetime.end(i64 8, i8* %i.phi) + ; CHECK: __asan_poison_stack_memory + ; CHECK: ret void + ret void +} diff --git a/test/Instrumentation/AddressSanitizer/test64.ll b/test/Instrumentation/AddressSanitizer/test64.ll index d544d77b93..6aa5c28850 100644 --- a/test/Instrumentation/AddressSanitizer/test64.ll +++ b/test/Instrumentation/AddressSanitizer/test64.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -asan -S | FileCheck %s 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 i32 @read_4_bytes(i32* %a) address_safety { +define i32 @read_4_bytes(i32* %a) sanitize_address { entry: %tmp1 = load i32* %a, align 4 ret i32 %tmp1 @@ -9,11 +9,11 @@ entry: ; CHECK: @read_4_bytes ; CHECK-NOT: ret ; CHECK: lshr {{.*}} 3 -; Check for ASAN's Offset for 64-bit (2^44) -; CHECK-NEXT: 17592186044416 +; Check for ASAN's Offset for 64-bit (2^44 or 7fff8000) +; CHECK-NEXT: {{17592186044416|2147450880}} ; CHECK: ret -define void @example_atomicrmw(i64* %ptr) nounwind uwtable address_safety { +define void @example_atomicrmw(i64* %ptr) nounwind uwtable sanitize_address { entry: %0 = atomicrmw add i64* %ptr, i64 1 seq_cst ret void @@ -24,7 +24,7 @@ entry: ; CHECK: atomicrmw ; CHECK: ret -define void @example_cmpxchg(i64* %ptr, i64 %compare_to, i64 %new_value) nounwind uwtable address_safety { +define void @example_cmpxchg(i64* %ptr, i64 %compare_to, i64 %new_value) nounwind uwtable sanitize_address { entry: %0 = cmpxchg i64* %ptr, i64 %compare_to, i64 %new_value seq_cst ret void |