1 ; RUN: opt < %s -passes=dfsan -dfsan-combine-pointer-labels-on-store=1 -S | FileCheck %s --check-prefixes=CHECK,COMBINE_PTR_LABEL
2 ; RUN: opt < %s -passes=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 define void @store0({} %v, ptr %p) {
7 ; CHECK-LABEL: @store0.dfsan
8 ; CHECK: store {} %v, ptr %p
16 define void @store8(i8 %v, ptr %p) {
17 ; CHECK-LABEL: @store8.dfsan
18 ; NO_COMBINE_PTR_LABEL: load i8, ptr @__dfsan_arg_tls
19 ; COMBINE_PTR_LABEL: load i8, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__dfsan_arg_tls to i64), i64 2) to ptr), align 2
21 ; COMBINE_PTR_LABEL: load i8, ptr @__dfsan_arg_tls
22 ; COMBINE_PTR_LABEL: or i8
23 ; CHECK: ptrtoint ptr {{.*}} i64
25 ; CHECK-NEXT: inttoptr i64 {{.*}} ptr
26 ; CHECK-NEXT: getelementptr i8, ptr
27 ; CHECK-NEXT: store i8
28 ; CHECK-NEXT: store i8 %v, ptr %p
29 ; CHECK-NEXT: ret void
35 define void @store16(i16 %v, ptr %p) {
36 ; CHECK-LABEL: @store16.dfsan
37 ; NO_COMBINE_PTR_LABEL: load i8, ptr @__dfsan_arg_tls
38 ; COMBINE_PTR_LABEL: load i8, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__dfsan_arg_tls to i64), i64 2) to ptr), align 2
39 ; COMBINE_PTR_LABEL: load i8, ptr @__dfsan_arg_tls
40 ; COMBINE_PTR_LABEL: or i8
41 ; CHECK: ptrtoint ptr {{.*}} i64
43 ; CHECK-NEXT: inttoptr i64 {{.*}} ptr
44 ; CHECK-NEXT: getelementptr i8, ptr
45 ; CHECK-NEXT: store i8
46 ; CHECK-NEXT: getelementptr i8, ptr
47 ; CHECK-NEXT: store i8
48 ; CHECK-NEXT: store i16 %v, ptr %p
49 ; CHECK-NEXT: ret void
55 define void @store32(i32 %v, ptr %p) {
56 ; CHECK-LABEL: @store32.dfsan
57 ; NO_COMBINE_PTR_LABEL: load i8, ptr @__dfsan_arg_tls
58 ; COMBINE_PTR_LABEL: load i8, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__dfsan_arg_tls to i64), i64 2) to ptr), align 2
59 ; COMBINE_PTR_LABEL: load i8, ptr @__dfsan_arg_tls
60 ; COMBINE_PTR_LABEL: or i8
61 ; CHECK: ptrtoint ptr {{.*}} i64
63 ; CHECK-NEXT: inttoptr i64 {{.*}} ptr
64 ; CHECK-NEXT: getelementptr i8, ptr
65 ; CHECK-NEXT: store i8
66 ; CHECK-NEXT: getelementptr i8, ptr
67 ; CHECK-NEXT: store i8
68 ; CHECK-NEXT: getelementptr i8, ptr
69 ; CHECK-NEXT: store i8
70 ; CHECK-NEXT: getelementptr i8, ptr
71 ; CHECK-NEXT: store i8
72 ; CHECK-NEXT: store i32 %v, ptr %p
73 ; CHECK-NEXT: ret void
79 define void @store64(i64 %v, ptr %p) {
80 ; CHECK-LABEL: @store64.dfsan
81 ; NO_COMBINE_PTR_LABEL: load i8, ptr @__dfsan_arg_tls
82 ; COMBINE_PTR_LABEL: load i8, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__dfsan_arg_tls to i64), i64 2) to ptr), align 2
83 ; COMBINE_PTR_LABEL: load i8, ptr @__dfsan_arg_tls
84 ; COMBINE_PTR_LABEL: or i8
85 ; CHECK: ptrtoint ptr {{.*}} i64
87 ; CHECK-NEXT: inttoptr i64 {{.*}} ptr
88 ; CHECK-COUNT-8: insertelement {{.*}} i8
89 ; CHECK-NEXT: getelementptr <8 x i8>
90 ; CHECK-NEXT: store <8 x i8>
91 ; CHECK-NEXT: store i64 %v, ptr %p
92 ; CHECK-NEXT: ret void
98 define void @store_zero(ptr %p) {
99 ; CHECK-LABEL: @store_zero.dfsan
100 ; NO_COMBINE_PTR_LABEL: store i32 0, ptr {{.*}}