1; Check that we don't replace uses in cmp with wrapper (which would accidentally optimize out the cmp). 2; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s 3target 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" 4target triple = "x86_64-unknown-linux-gnu" 5 6; CHECK: @__dfsan_shadow_width_bits = weak_odr constant i32 [[#SBITS:]] 7; CHECK: @__dfsan_shadow_width_bytes = weak_odr constant i32 [[#SBYTES:]] 8 9; CHECK: declare extern_weak i8 @ExternWeak(i8) 10declare extern_weak i8 @ExternWeak(i8) 11 12define noundef i8 @call_if_exists() local_unnamed_addr { 13 ; CHECK-LABEL: @call_if_exists.dfsan 14 ; Ensure comparison is preserved 15 ; CHECK: br i1 icmp ne ([[FUNCPTRTY:.*]] @ExternWeak, [[FUNCPTRTY]] null), label %use_func, label %avoid_func 16 br i1 icmp ne (i8 (i8)* @ExternWeak, i8 (i8)* null), label %use_func, label %avoid_func 17 18use_func: 19 ; CHECK: use_func: 20 ; Ensure extern weak function is validated before being called. 21 ; CHECK: call void @__dfsan_wrapper_extern_weak_null({{[^,]*}}@ExternWeak{{[^,]*}}, {{.*}}) 22 ; CHECK-NEXT: call i8 @ExternWeak(i8 {{.*}}) 23 %1 = call i8 @ExternWeak(i8 4) 24 br label %end 25 26avoid_func: 27 ; CHECK: avoid_func: 28 br label %end 29 30end: 31 ; CHECK: end: 32 %r = phi i8 [ %1, %use_func ], [ 0, %avoid_func ] 33 ret i8 %r 34} 35 36