34 lines · plain
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 %s3target 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.dfsan11 ; Ensure comparison is preserved12 ; CHECK: %cmp = icmp ne [[FUNCPTRTY:.*]] @ExternWeak, null13 %cmp = icmp ne ptr @ExternWeak, null14 br i1 %cmp, label %use_func, label %avoid_func15 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 %end23 24avoid_func:25 ; CHECK: avoid_func:26 br label %end27 28end:29 ; CHECK: end:30 %r = phi i8 [ %1, %use_func ], [ 0, %avoid_func ]31 ret i8 %r32}33 34