1 ; RUN: opt < %s -passes=dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck -enable-var-scope %s
2 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"
3 target triple = "x86_64-unknown-linux-gnu"
5 ; CHECK: i32 @discard(i32 %a, i32 %b)
6 define i32 @discard(i32 %a, i32 %b) {
10 ; CHECK: i32 @functional(i32 %a, i32 %b)
11 define i32 @functional(i32 %a, i32 %b) {
16 @discardg = alias ptr (i32), ptr @g
18 declare void @custom1(i32 %a, i32 %b)
20 declare i32 @custom2(i32 %a, i32 %b)
22 declare void @custom3(i32 %a, ...)
24 declare i32 @custom4(i32 %a, ...)
26 declare void @customcb(ptr %cb)
31 define void @f(i32 %x) {
32 ; CHECK: %[[LABELVA2:.*]] = alloca [2 x i8]
33 ; CHECK: %[[LABELVA1:.*]] = alloca [2 x i8]
34 ; CHECK: %[[LABELRETURN:.*]] = alloca i8
36 ; CHECK: call void @__dfsw_custom1(i32 1, i32 2, i8 zeroext 0, i8 zeroext 0)
37 call void @custom1(i32 1, i32 2)
39 ; CHECK: call i32 @__dfsw_custom2(i32 1, i32 2, i8 zeroext 0, i8 zeroext 0, ptr %[[LABELRETURN]])
40 call i32 @custom2(i32 1, i32 2)
42 ; CHECK: call void @__dfsw_customcb({{.*}} @cb.dfsan, i8 zeroext 0)
43 call void @customcb(ptr @cb)
45 ; CHECK: %[[LABELVA1_0:.*]] = getelementptr inbounds [2 x i8], ptr %[[LABELVA1]], i32 0, i32 0
46 ; CHECK: store i8 0, ptr %[[LABELVA1_0]]
47 ; CHECK: %[[LABELVA1_1:.*]] = getelementptr inbounds [2 x i8], ptr %[[LABELVA1]], i32 0, i32 1
48 ; CHECK: store i8 %{{.*}}, ptr %[[LABELVA1_1]]
49 ; CHECK: %[[LABELVA1_0A:.*]] = getelementptr inbounds [2 x i8], ptr %[[LABELVA1]], i32 0, i32 0
50 ; CHECK: call void (i32, i8, ptr, ...) @__dfsw_custom3(i32 1, i8 zeroext 0, ptr %[[LABELVA1_0A]], i32 2, i32 %{{.*}})
52 call void (i32, ...) @custom3(i32 1, i32 2, i32 %x)
54 ; CHECK: %[[LABELVA2_0:.*]] = getelementptr inbounds [2 x i8], ptr %[[LABELVA2]], i32 0, i32 0
55 ; CHECK: %[[LABELVA2_0A:.*]] = getelementptr inbounds [2 x i8], ptr %[[LABELVA2]], i32 0, i32 0
56 ; CHECK: call i32 (i32, i8, ptr, ptr, ...) @__dfsw_custom4(i32 1, i8 zeroext 0, ptr %[[LABELVA2_0A]], ptr %[[LABELRETURN]], i32 2, i32 3)
57 call i32 (i32, ...) @custom4(i32 1, i32 2, i32 3)
64 ; CHECK: ret {{.*}} @"dfsw$custom2"
68 ; CHECK: define ptr @discardg(i32 %0)
69 ; CHECK: %[[CALL:.*]] = call ptr @g.dfsan(i32 %0)
70 ; CHECK: load {{.*}} @__dfsan_retval_tls
73 ; CHECK: define i32 @adiscard.dfsan(i32 %0, i32 %1)
74 ; CHECK: %[[CALL:.*]] = call i32 @discard(i32 %0, i32 %1)
76 @adiscard = alias i32 (i32, i32), ptr @discard
78 ; CHECK: define linkonce_odr i32 @"dfsw$custom2"(i32 %0, i32 %1)
79 ; CHECK: %[[LABELRETURN2:.*]] = alloca i8
80 ; CHECK: %[[RV:.*]] = call i32 @__dfsw_custom2(i32 {{.*}}, i32 {{.*}}, i8 {{.*}}, i8 {{.*}}, ptr %[[LABELRETURN2]])
81 ; CHECK: %[[RVSHADOW:.*]] = load i8, ptr %[[LABELRETURN2]]
82 ; CHECK: store {{.*}} @__dfsan_retval_tls
85 ; CHECK: define linkonce_odr void @"dfsw$custom3"(i32 %0, ...)
86 ; CHECK: call void @__dfsan_vararg_wrapper(ptr
89 ; CHECK: define linkonce_odr i32 @"dfsw$custom4"(i32 %0, ...)
91 ; CHECK: declare void @__dfsw_custom1(i32, i32, i8, i8)
92 ; CHECK: declare i32 @__dfsw_custom2(i32, i32, i8, i8, ptr)
94 ; CHECK: declare void @__dfsw_custom3(i32, i8, ptr, ...)
95 ; CHECK: declare i32 @__dfsw_custom4(i32, i8, ptr, ptr, ...)