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
3 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"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; CHECK: declare extern_weak i8 @ExternWeak(i8)
7 declare extern_weak i8 @ExternWeak(i8)
9 define noundef i8 @call_if_exists() local_unnamed_addr {
10 ; CHECK-LABEL: @call_if_exists.dfsan
11 ; Ensure comparison is preserved
12 ; CHECK: br i1 icmp ne ([[FUNCPTRTY:.*]] @ExternWeak, [[FUNCPTRTY]] null), label %use_func, label %avoid_func
13 br i1 icmp ne (ptr @ExternWeak, ptr null), label %use_func, label %avoid_func
17 ; Ensure extern weak function is validated before being called.
18 ; CHECK: call void @__dfsan_wrapper_extern_weak_null({{[^,]*}}@ExternWeak{{[^,]*}}, {{.*}})
19 ; CHECK-NEXT: call i8 @ExternWeak(i8 {{.*}})
20 %1 = call i8 @ExternWeak(i8 4)
29 %r = phi i8 [ %1, %use_func ], [ 0, %avoid_func ]