76 lines · plain
1; ASan shouldn't instrument code added by UBSan.2 3; RUN: opt < %s -passes=asan -S | FileCheck %s4; RUN: opt < %s -passes=asan -asan-detect-invalid-pointer-cmp -S | FileCheck %s --check-prefixes=NOCMP5 6target 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"7target triple = "x86_64-unknown-linux-gnu"8 9%struct.A = type { ptr }10declare void @__ubsan_handle_dynamic_type_cache_miss(ptr, i64, i64) uwtable11declare void @__ubsan_handle_pointer_overflow(ptr, i64, i64) uwtable12@__ubsan_vptr_type_cache = external global [128 x i64]13@.src = private unnamed_addr constant [19 x i8] c"tmp/ubsan/vptr.cpp\00", align 114@0 = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" }15@_ZTI1A = external constant ptr16@1 = private unnamed_addr global { { ptr, i32, i32 }, ptr, ptr, i8 } { { ptr, i32, i32 } { ptr @.src, i32 2, i32 18 }, ptr @0, ptr @_ZTI1A, i8 4 }17@2 = private unnamed_addr global { { ptr, i32, i32 } } { { ptr, i32, i32 } { ptr @.src, i32 24, i32 25 } }18 19define void @_Z3BarP1A(ptr %a) uwtable sanitize_address {20; CHECK-LABEL: define void @_Z3BarP1A21entry:22 %vtable = load ptr, ptr %a, align 823; CHECK: __asan_report_load824 %0 = load ptr, ptr %vtable, align 825; CHECK: __asan_report_load826 %1 = ptrtoint ptr %vtable to i6427 %2 = xor i64 %1, -303164226014115343, !nosanitize !028 %3 = mul i64 %2, -7070675565921424023, !nosanitize !029 %4 = lshr i64 %3, 47, !nosanitize !030 %5 = xor i64 %3, %1, !nosanitize !031 %6 = xor i64 %5, %4, !nosanitize !032 %7 = mul i64 %6, -7070675565921424023, !nosanitize !033 %8 = lshr i64 %7, 47, !nosanitize !034 %9 = xor i64 %8, %7, !nosanitize !035 %10 = mul i64 %9, -7070675565921424023, !nosanitize !036 %11 = and i64 %10, 127, !nosanitize !037 %12 = getelementptr inbounds [128 x i64], ptr @__ubsan_vptr_type_cache, i64 0, i64 %11, !nosanitize !038; CHECK-NOT: __asan_report_load839 %13 = load i64, ptr %12, align 8, !nosanitize !040 %14 = icmp eq i64 %13, %10, !nosanitize !041 br i1 %14, label %cont, label %handler.dynamic_type_cache_miss, !nosanitize !042 43handler.dynamic_type_cache_miss: ; preds = %entry44 %15 = ptrtoint ptr %a to i64, !nosanitize !045 tail call void @__ubsan_handle_dynamic_type_cache_miss(ptr @1, i64 %15, i64 %10) #2, !nosanitize !046 br label %cont, !nosanitize !047 48cont: ; preds = %handler.dynamic_type_cache_miss, %entry49 tail call void %0(ptr %a)50; CHECK: ret void51 ret void52}53 54define void @_Z3foov() uwtable sanitize_address {55; NOCMP-LABEL: define void @_Z3foov56entry:57 %bar = alloca [10 x i8], align 158 %arrayidx = getelementptr inbounds [10 x i8], ptr %bar, i64 0, i64 459 %0 = ptrtoint ptr %bar to i64, !nosanitize !060; NOCMP-NOT: call void @__sanitizer_ptr_cmp61 %1 = icmp ult ptr %bar, inttoptr (i64 -4 to ptr), !nosanitize !062 br i1 %1, label %cont, label %handler.pointer_overflow, !nosanitize !063 64handler.pointer_overflow: ; preds = %entry65 %2 = add i64 %0, 4, !nosanitize !066 call void @__ubsan_handle_pointer_overflow(ptr @2, i64 %0, i64 %2), !nosanitize !067 br label %cont, !nosanitize !068 69cont: ; preds = %handler.pointer_overflow, %entry70 store i8 0, ptr %arrayidx, align 171; NOCMP: ret void72 ret void73}74 75!0 = !{}76