• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -dfsan -dfsan-args-abi -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s
2; RUN: opt < %s -dfsan                 -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s
3
4target triple = "x86_64-unknown-linux-gnu"
5
6; Declare custom functions.  Inputs/abilist.txt causes any function with a
7; name matching /custom.*/ to be a custom function.
8declare i32 @custom_fun_one_callback(i8 (i32, double)* %callback_arg)
9declare i32 @custom_fun_two_callbacks(
10  i8 (i32, double)* %callback_arg1,
11  i64 %an_int,
12  i8 (i32, double)* %callback_arg2
13)
14
15declare i8 @a_callback_fun(i32, double)
16
17; CHECK-LABEL: @"dfs$call_custom_funs_with_callbacks"
18define void @call_custom_funs_with_callbacks(i8 (i32, double)* %callback_arg) {
19  ;; The callback should have attribute 'nonnull':
20  ; CHECK: call signext i32 @__dfsw_custom_fun_one_callback(
21  ; CHECK: nonnull @"dfst0$custom_fun_one_callback"
22  %call1 = call signext i32 @custom_fun_one_callback(
23    i8 (i32, double)* nonnull @a_callback_fun
24  )
25
26  ;; Call a custom function with two callbacks.  Check their annotations.
27  ; CHECK: call i32 @__dfsw_custom_fun_two_callbacks(
28  ; CHECK: nonnull @"dfst0$custom_fun_two_callbacks"
29  ; CHECK: i64 12345
30  ; CHECK: noalias @"dfst2$custom_fun_two_callbacks"
31  %call2 = call i32 @custom_fun_two_callbacks(
32    i8 (i32, double)* nonnull @a_callback_fun,
33    i64 12345,
34    i8 (i32, double)* noalias @a_callback_fun
35  )
36  ret void
37}
38