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