Skip to content

Commit cbbf1eb

Browse files
committed
[test][InstCombine] Use opaque pointers in wcslen test cases. NFC
1 parent ac135f9 commit cbbf1eb

File tree

4 files changed

+118
-141
lines changed

4 files changed

+118
-141
lines changed

llvm/test/Transforms/InstCombine/wcslen-1.ll

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
77

8-
declare i64 @wcslen(i32*)
8+
declare i64 @wcslen(ptr)
99

1010
!0 = !{i32 1, !"wchar_size", i32 4}
1111
!llvm.module.flags = !{!0}
@@ -22,34 +22,31 @@ define i64 @test_simplify1() {
2222
; CHECK-LABEL: @test_simplify1(
2323
; CHECK-NEXT: ret i64 5
2424
;
25-
%hello_p = getelementptr [6 x i32], [6 x i32]* @hello, i64 0, i64 0
26-
%hello_l = call i64 @wcslen(i32* %hello_p)
25+
%hello_l = call i64 @wcslen(ptr @hello)
2726
ret i64 %hello_l
2827
}
2928

3029
define i64 @test_simplify2() {
3130
; CHECK-LABEL: @test_simplify2(
3231
; CHECK-NEXT: ret i64 0
3332
;
34-
%null_p = getelementptr [1 x i32], [1 x i32]* @null, i64 0, i64 0
35-
%null_l = call i64 @wcslen(i32* %null_p)
33+
%null_l = call i64 @wcslen(ptr @null)
3634
ret i64 %null_l
3735
}
3836

3937
define i64 @test_simplify3() {
4038
; CHECK-LABEL: @test_simplify3(
4139
; CHECK-NEXT: ret i64 0
4240
;
43-
%null_hello_p = getelementptr [7 x i32], [7 x i32]* @null_hello, i64 0, i64 0
44-
%null_hello_l = call i64 @wcslen(i32* %null_hello_p)
41+
%null_hello_l = call i64 @wcslen(ptr @null_hello)
4542
ret i64 %null_hello_l
4643
}
4744

4845
define i64 @test_simplify4() {
4946
; CHECK-LABEL: @test_simplify4(
5047
; CHECK-NEXT: ret i64 0
5148
;
52-
%len = tail call i64 @wcslen(i32* @nullstring) nounwind
49+
%len = tail call i64 @wcslen(ptr @nullstring) nounwind
5350
ret i64 %len
5451
}
5552

@@ -59,19 +56,18 @@ define i1 @test_simplify5() {
5956
; CHECK-LABEL: @test_simplify5(
6057
; CHECK-NEXT: ret i1 false
6158
;
62-
%hello_p = getelementptr [6 x i32], [6 x i32]* @hello, i64 0, i64 0
63-
%hello_l = call i64 @wcslen(i32* %hello_p)
59+
%hello_l = call i64 @wcslen(ptr @hello)
6460
%eq_hello = icmp eq i64 %hello_l, 0
6561
ret i1 %eq_hello
6662
}
6763

68-
define i1 @test_simplify6(i32* %str_p) {
64+
define i1 @test_simplify6(ptr %str_p) {
6965
; CHECK-LABEL: @test_simplify6(
70-
; CHECK-NEXT: [[CHAR0:%.*]] = load i32, i32* [[STR_P:%.*]], align 4
66+
; CHECK-NEXT: [[CHAR0:%.*]] = load i32, ptr [[STR_P:%.*]], align 4
7167
; CHECK-NEXT: [[EQ_NULL:%.*]] = icmp eq i32 [[CHAR0]], 0
7268
; CHECK-NEXT: ret i1 [[EQ_NULL]]
7369
;
74-
%str_l = call i64 @wcslen(i32* %str_p)
70+
%str_l = call i64 @wcslen(ptr %str_p)
7571
%eq_null = icmp eq i64 %str_l, 0
7672
ret i1 %eq_null
7773
}
@@ -82,19 +78,18 @@ define i1 @test_simplify7() {
8278
; CHECK-LABEL: @test_simplify7(
8379
; CHECK-NEXT: ret i1 true
8480
;
85-
%hello_p = getelementptr [6 x i32], [6 x i32]* @hello, i64 0, i64 0
86-
%hello_l = call i64 @wcslen(i32* %hello_p)
81+
%hello_l = call i64 @wcslen(ptr @hello)
8782
%ne_hello = icmp ne i64 %hello_l, 0
8883
ret i1 %ne_hello
8984
}
9085

91-
define i1 @test_simplify8(i32* %str_p) {
86+
define i1 @test_simplify8(ptr %str_p) {
9287
; CHECK-LABEL: @test_simplify8(
93-
; CHECK-NEXT: [[CHAR0:%.*]] = load i32, i32* [[STR_P:%.*]], align 4
88+
; CHECK-NEXT: [[CHAR0:%.*]] = load i32, ptr [[STR_P:%.*]], align 4
9489
; CHECK-NEXT: [[NE_NULL:%.*]] = icmp ne i32 [[CHAR0]], 0
9590
; CHECK-NEXT: ret i1 [[NE_NULL]]
9691
;
97-
%str_l = call i64 @wcslen(i32* %str_p)
92+
%str_l = call i64 @wcslen(ptr %str_p)
9893
%ne_null = icmp ne i64 %str_l, 0
9994
ret i1 %ne_null
10095
}
@@ -104,10 +99,8 @@ define i64 @test_simplify9(i1 %x) {
10499
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[X:%.*]], i64 5, i64 6
105100
; CHECK-NEXT: ret i64 [[TMP1]]
106101
;
107-
%hello = getelementptr [6 x i32], [6 x i32]* @hello, i64 0, i64 0
108-
%longer = getelementptr [7 x i32], [7 x i32]* @longer, i64 0, i64 0
109-
%s = select i1 %x, i32* %hello, i32* %longer
110-
%l = call i64 @wcslen(i32* %s)
102+
%s = select i1 %x, ptr @hello, ptr @longer
103+
%l = call i64 @wcslen(ptr %s)
111104
ret i64 %l
112105
}
113106

@@ -120,8 +113,8 @@ define i64 @test_simplify10(i32 %x) {
120113
; CHECK-NEXT: [[TMP2:%.*]] = sub nsw i64 5, [[TMP1]]
121114
; CHECK-NEXT: ret i64 [[TMP2]]
122115
;
123-
%hello_p = getelementptr inbounds [6 x i32], [6 x i32]* @hello, i32 0, i32 %x
124-
%hello_l = call i64 @wcslen(i32* %hello_p)
116+
%hello_p = getelementptr inbounds [6 x i32], ptr @hello, i32 0, i32 %x
117+
%hello_l = call i64 @wcslen(ptr %hello_p)
125118
ret i64 %hello_l
126119
}
127120

@@ -135,20 +128,19 @@ define i64 @test_simplify11(i32 %x) {
135128
; CHECK-NEXT: ret i64 [[TMP1]]
136129
;
137130
%and = and i32 %x, 7
138-
%hello_p = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i32 0, i32 %and
139-
%hello_l = call i64 @wcslen(i32* %hello_p)
131+
%hello_p = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i32 0, i32 %and
132+
%hello_l = call i64 @wcslen(ptr %hello_p)
140133
ret i64 %hello_l
141134
}
142135

143136
; Check cases that shouldn't be simplified.
144137

145138
define i64 @test_no_simplify1() {
146139
; CHECK-LABEL: @test_no_simplify1(
147-
; CHECK-NEXT: [[A_L:%.*]] = call i64 @wcslen(i32* nonnull getelementptr inbounds ([32 x i32], [32 x i32]* @a, i64 0, i64 0))
140+
; CHECK-NEXT: [[A_L:%.*]] = call i64 @wcslen(ptr nonnull @a)
148141
; CHECK-NEXT: ret i64 [[A_L]]
149142
;
150-
%a_p = getelementptr [32 x i32], [32 x i32]* @a, i64 0, i64 0
151-
%a_l = call i64 @wcslen(i32* %a_p)
143+
%a_l = call i64 @wcslen(ptr @a)
152144
ret i64 %a_l
153145
}
154146

@@ -157,24 +149,24 @@ define i64 @test_no_simplify1() {
157149
define i64 @test_no_simplify2(i32 %x) {
158150
; CHECK-LABEL: @test_no_simplify2(
159151
; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[X:%.*]] to i64
160-
; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i32], [7 x i32]* @null_hello, i64 0, i64 [[TMP1]]
161-
; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i32* nonnull [[HELLO_P]])
152+
; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i32], ptr @null_hello, i64 0, i64 [[TMP1]]
153+
; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr nonnull [[HELLO_P]])
162154
; CHECK-NEXT: ret i64 [[HELLO_L]]
163155
;
164-
%hello_p = getelementptr inbounds [7 x i32], [7 x i32]* @null_hello, i32 0, i32 %x
165-
%hello_l = call i64 @wcslen(i32* %hello_p)
156+
%hello_p = getelementptr inbounds [7 x i32], ptr @null_hello, i32 0, i32 %x
157+
%hello_l = call i64 @wcslen(ptr %hello_p)
166158
ret i64 %hello_l
167159
}
168160

169161
define i64 @test_no_simplify2_no_null_opt(i32 %x) #0 {
170162
; CHECK-LABEL: @test_no_simplify2_no_null_opt(
171163
; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[X:%.*]] to i64
172-
; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i32], [7 x i32]* @null_hello, i64 0, i64 [[TMP1]]
173-
; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i32* [[HELLO_P]])
164+
; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [7 x i32], ptr @null_hello, i64 0, i64 [[TMP1]]
165+
; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr [[HELLO_P]])
174166
; CHECK-NEXT: ret i64 [[HELLO_L]]
175167
;
176-
%hello_p = getelementptr inbounds [7 x i32], [7 x i32]* @null_hello, i32 0, i32 %x
177-
%hello_l = call i64 @wcslen(i32* %hello_p)
168+
%hello_p = getelementptr inbounds [7 x i32], ptr @null_hello, i32 0, i32 %x
169+
%hello_l = call i64 @wcslen(ptr %hello_p)
178170
ret i64 %hello_l
179171
}
180172

@@ -184,27 +176,27 @@ define i64 @test_no_simplify3(i32 %x) {
184176
; CHECK-LABEL: @test_no_simplify3(
185177
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 15
186178
; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[AND]] to i64
187-
; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i64 0, i64 [[TMP1]]
188-
; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i32* nonnull [[HELLO_P]])
179+
; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i64 0, i64 [[TMP1]]
180+
; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr nonnull [[HELLO_P]])
189181
; CHECK-NEXT: ret i64 [[HELLO_L]]
190182
;
191183
%and = and i32 %x, 15
192-
%hello_p = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i32 0, i32 %and
193-
%hello_l = call i64 @wcslen(i32* %hello_p)
184+
%hello_p = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i32 0, i32 %and
185+
%hello_l = call i64 @wcslen(ptr %hello_p)
194186
ret i64 %hello_l
195187
}
196188

197189
define i64 @test_no_simplify3_no_null_opt(i32 %x) #0 {
198190
; CHECK-LABEL: @test_no_simplify3_no_null_opt(
199191
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 15
200192
; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[AND]] to i64
201-
; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i64 0, i64 [[TMP1]]
202-
; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(i32* [[HELLO_P]])
193+
; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i64 0, i64 [[TMP1]]
194+
; CHECK-NEXT: [[HELLO_L:%.*]] = call i64 @wcslen(ptr [[HELLO_P]])
203195
; CHECK-NEXT: ret i64 [[HELLO_L]]
204196
;
205197
%and = and i32 %x, 15
206-
%hello_p = getelementptr inbounds [13 x i32], [13 x i32]* @null_hello_mid, i32 0, i32 %and
207-
%hello_l = call i64 @wcslen(i32* %hello_p)
198+
%hello_p = getelementptr inbounds [13 x i32], ptr @null_hello_mid, i32 0, i32 %and
199+
%hello_l = call i64 @wcslen(ptr %hello_p)
208200
ret i64 %hello_l
209201
}
210202

@@ -218,7 +210,7 @@ define i64 @test_simplify12() {
218210
; CHECK-LABEL: @test_simplify12(
219211
; CHECK-NEXT: ret i64 0
220212
;
221-
%l = call i64 @wcslen(i32* bitcast ([1 x i16]* @str16 to i32*))
213+
%l = call i64 @wcslen(ptr @str16)
222214
ret i64 %l
223215
}
224216

0 commit comments

Comments
 (0)