xref: /llvm-project/llvm/test/Instrumentation/DataFlowSanitizer/custom_fun_callback_attributes.ll (revision 66c3444f4cc5c1f70ec33e7806f8236a39b6adc2)
1; RUN: opt < %s -passes=dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s
2target triple = "x86_64-unknown-linux-gnu"
3
4; Declare custom functions.  Inputs/abilist.txt causes any function with a
5; name matching /custom.*/ to be a custom function.
6declare i32 @custom_fun_one_callback(ptr %callback_arg)
7declare i32 @custom_fun_two_callbacks(
8  ptr %callback_arg1,
9  i64 %an_int,
10  ptr %callback_arg2
11)
12
13declare i8 @a_callback_fun(i32, double)
14
15; CHECK-LABEL: @call_custom_funs_with_callbacks.dfsan
16define void @call_custom_funs_with_callbacks(ptr %callback_arg) {
17  ;; The callback should have attribute 'nonnull':
18  ; CHECK: call signext i32 @__dfsw_custom_fun_one_callback(
19  %call1 = call signext i32 @custom_fun_one_callback(
20    ptr nonnull @a_callback_fun
21  )
22
23  ;; Call a custom function with two callbacks.  Check their annotations.
24  ; CHECK: call i32 @__dfsw_custom_fun_two_callbacks(
25  ; CHECK: i64 12345
26  %call2 = call i32 @custom_fun_two_callbacks(
27    ptr nonnull @a_callback_fun,
28    i64 12345,
29    ptr noalias @a_callback_fun
30  )
31  ret void
32}
33