1 ; RUN: opt < %s -dfsan -dfsan-combine-pointer-labels-on-store=1 -S | FileCheck %s --check-prefixes=CHECK,COMBINE_PTR_LABEL
2 ; RUN: opt < %s -dfsan -dfsan-combine-pointer-labels-on-store=0 -S | FileCheck %s --check-prefixes=CHECK,NO_COMBINE_PTR_LABEL
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: @__dfsan_shadow_width_bits = weak_odr constant i32 [[#SBITS:]]
7 ; CHECK: @__dfsan_shadow_width_bytes = weak_odr constant i32 [[#SBYTES:]]
9 define void @store0({} %v, {}* %p) {
10 ; CHECK-LABEL: @store0.dfsan
11 ; CHECK: store {} %v, {}* %p
19 define void @store8(i8 %v, i8* %p) {
20 ; CHECK-LABEL: @store8.dfsan
21 ; CHECK: load i[[#SBITS]], i[[#SBITS]]* {{.*}} @__dfsan_arg_tls
22 ; COMBINE_PTR_LABEL: load i[[#SBITS]], i[[#SBITS]]* {{.*}} @__dfsan_arg_tls
23 ; COMBINE_PTR_LABEL: or i[[#SBITS]]
24 ; CHECK: ptrtoint i8* {{.*}} i64
26 ; CHECK-NEXT: inttoptr i64 {{.*}} i[[#SBITS]]*
27 ; CHECK-NEXT: getelementptr i[[#SBITS]], i[[#SBITS]]*
28 ; CHECK-NEXT: store i[[#SBITS]]
29 ; CHECK-NEXT: store i8 %v, i8* %p
30 ; CHECK-NEXT: ret void
36 define void @store16(i16 %v, i16* %p) {
37 ; CHECK-LABEL: @store16.dfsan
38 ; CHECK: load i[[#SBITS]], i[[#SBITS]]* {{.*}} @__dfsan_arg_tls
39 ; COMBINE_PTR_LABEL: load i[[#SBITS]], i[[#SBITS]]* {{.*}} @__dfsan_arg_tls
40 ; COMBINE_PTR_LABEL: or i[[#SBITS]]
41 ; CHECK: ptrtoint i16* {{.*}} i64
43 ; CHECK-NEXT: inttoptr i64 {{.*}} i[[#SBITS]]*
44 ; CHECK-NEXT: getelementptr i[[#SBITS]], i[[#SBITS]]*
45 ; CHECK-NEXT: store i[[#SBITS]]
46 ; CHECK-NEXT: getelementptr i[[#SBITS]], i[[#SBITS]]*
47 ; CHECK-NEXT: store i[[#SBITS]]
48 ; CHECK-NEXT: store i16 %v, i16* %p
49 ; CHECK-NEXT: ret void
55 define void @store32(i32 %v, i32* %p) {
56 ; CHECK-LABEL: @store32.dfsan
57 ; CHECK: load i[[#SBITS]], i[[#SBITS]]* {{.*}} @__dfsan_arg_tls
58 ; COMBINE_PTR_LABEL: load i[[#SBITS]], i[[#SBITS]]* {{.*}} @__dfsan_arg_tls
59 ; COMBINE_PTR_LABEL: or i[[#SBITS]]
60 ; CHECK: ptrtoint i32* {{.*}} i64
62 ; CHECK-NEXT: inttoptr i64 {{.*}} i[[#SBITS]]*
63 ; CHECK-NEXT: getelementptr i[[#SBITS]], i[[#SBITS]]*
64 ; CHECK-NEXT: store i[[#SBITS]]
65 ; CHECK-NEXT: getelementptr i[[#SBITS]], i[[#SBITS]]*
66 ; CHECK-NEXT: store i[[#SBITS]]
67 ; CHECK-NEXT: getelementptr i[[#SBITS]], i[[#SBITS]]*
68 ; CHECK-NEXT: store i[[#SBITS]]
69 ; CHECK-NEXT: getelementptr i[[#SBITS]], i[[#SBITS]]*
70 ; CHECK-NEXT: store i[[#SBITS]]
71 ; CHECK-NEXT: store i32 %v, i32* %p
72 ; CHECK-NEXT: ret void
78 define void @store64(i64 %v, i64* %p) {
79 ; CHECK-LABEL: @store64.dfsan
80 ; CHECK: load i[[#SBITS]], i[[#SBITS]]* {{.*}} @__dfsan_arg_tls
81 ; COMBINE_PTR_LABEL: load i[[#SBITS]], i[[#SBITS]]* {{.*}} @__dfsan_arg_tls
82 ; COMBINE_PTR_LABEL: or i[[#SBITS]]
83 ; CHECK: ptrtoint i64* {{.*}} i64
85 ; CHECK-NEXT: inttoptr i64 {{.*}} i[[#SBITS]]*
86 ; CHECK-COUNT-8: insertelement {{.*}} i[[#SBITS]]
87 ; CHECK-NEXT: bitcast i[[#SBITS]]* {{.*}} <8 x i[[#SBITS]]>*
88 ; CHECK-NEXT: getelementptr <8 x i[[#SBITS]]>
89 ; CHECK-NEXT: store <8 x i[[#SBITS]]>
90 ; CHECK-NEXT: store i64 %v, i64* %p
91 ; CHECK-NEXT: ret void
97 define void @store_zero(i32* %p) {
98 ; CHECK-LABEL: @store_zero.dfsan
99 ; NO_COMBINE_PTR_LABEL: bitcast i[[#SBITS]]* {{.*}} to i[[#mul(4, SBITS)]]*
100 ; NO_COMBINE_PTR_LABEL: store i[[#mul(4, SBITS)]] 0, i[[#mul(4, SBITS)]]* {{.*}}