Skip to content

Commit 8927458

Browse files
committed
[test][InstCombine] Update even more test cases to use opaque pointer
These tests cases were converted using the script at https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34. Needed to also re-run update_test_checks.py, otherwise some of them would fail.
1 parent dc2b66b commit 8927458

File tree

13 files changed

+483
-555
lines changed

13 files changed

+483
-555
lines changed

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

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,98 +14,88 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
1414
@percent_s = constant [3 x i8] c"%s\00"
1515
@percent_m = constant [3 x i8] c"%m\00"
1616

17-
declare i32 @fprintf(%FILE*, i8*, ...)
17+
declare i32 @fprintf(ptr, ptr, ...)
1818

1919
; Check fprintf(fp, "foo") -> fwrite("foo", 3, 1, fp).
2020

21-
define void @test_simplify1(%FILE* %fp) {
21+
define void @test_simplify1(ptr %fp) {
2222
; CHECK-LABEL: @test_simplify1(
23-
%fmt = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
24-
call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt)
25-
; CHECK-NEXT: call i32 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0), i32 12, i32 1, %FILE* %fp)
23+
call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @hello_world)
24+
; CHECK-NEXT: call i32 @fwrite(ptr nonnull @hello_world, i32 12, i32 1, ptr %fp)
2625
ret void
2726
; CHECK-NEXT: ret void
2827
}
2928

3029
; Check fprintf(fp, "%c", chr) -> fputc(chr, fp).
3130

32-
define void @test_simplify2(%FILE* %fp) {
31+
define void @test_simplify2(ptr %fp) {
3332
; CHECK-LABEL: @test_simplify2(
34-
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_c, i32 0, i32 0
35-
call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt, i8 104)
36-
; CHECK-NEXT: call i32 @fputc(i32 104, %FILE* %fp)
33+
call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @percent_c, i8 104)
34+
; CHECK-NEXT: call i32 @fputc(i32 104, ptr %fp)
3735
ret void
3836
; CHECK-NEXT: ret void
3937
}
4038

4139
; Check fprintf(fp, "%s", str) -> fputs(str, fp).
4240
; NOTE: The fputs simplifier simplifies this further to fwrite.
4341

44-
define void @test_simplify3(%FILE* %fp) {
42+
define void @test_simplify3(ptr %fp) {
4543
; CHECK-LABEL: @test_simplify3(
46-
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_s, i32 0, i32 0
47-
%str = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
48-
call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt, i8* %str)
49-
; CHECK-NEXT: call i32 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0), i32 12, i32 1, %FILE* %fp)
44+
call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @percent_s, ptr @hello_world)
45+
; CHECK-NEXT: call i32 @fwrite(ptr nonnull @hello_world, i32 12, i32 1, ptr %fp)
5046
ret void
5147
; CHECK-NEXT: ret void
5248
}
5349

5450
; Check fprintf(fp, fmt, ...) -> fiprintf(fp, fmt, ...) if no floating point.
5551

56-
define void @test_simplify4(%FILE* %fp) {
52+
define void @test_simplify4(ptr %fp) {
5753
; CHECK-IPRINTF-LABEL: @test_simplify4(
58-
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_d, i32 0, i32 0
59-
call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt, i32 187)
60-
; CHECK-IPRINTF-NEXT: call i32 (%FILE*, i8*, ...) @fiprintf(%FILE* %fp, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @percent_d, i32 0, i32 0), i32 187)
54+
call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @percent_d, i32 187)
55+
; CHECK-IPRINTF-NEXT: call i32 (ptr, ptr, ...) @fiprintf(ptr %fp, ptr nonnull @percent_d, i32 187)
6156
ret void
6257
; CHECK-IPRINTF-NEXT: ret void
6358
}
6459

65-
define void @test_simplify5(%FILE* %fp) {
60+
define void @test_simplify5(ptr %fp) {
6661
; CHECK-LABEL: @test_simplify5(
67-
%fmt = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
68-
call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt) [ "deopt"() ]
69-
; CHECK-NEXT: call i32 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0), i32 12, i32 1, %FILE* %fp) [ "deopt"() ]
62+
call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @hello_world) [ "deopt"() ]
63+
; CHECK-NEXT: call i32 @fwrite(ptr nonnull @hello_world, i32 12, i32 1, ptr %fp) [ "deopt"() ]
7064
ret void
7165
; CHECK-NEXT: ret void
7266
}
7367

74-
define void @test_no_simplify1(%FILE* %fp) {
68+
define void @test_no_simplify1(ptr %fp) {
7569
; CHECK-IPRINTF-LABEL: @test_no_simplify1(
76-
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_f, i32 0, i32 0
77-
call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt, double 1.87)
78-
; CHECK-IPRINTF-NEXT: call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @percent_f, i32 0, i32 0), double 1.870000e+00)
70+
call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @percent_f, double 1.87)
71+
; CHECK-IPRINTF-NEXT: call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr nonnull @percent_f, double 1.870000e+00)
7972
ret void
8073
; CHECK-IPRINTF-NEXT: ret void
8174
}
8275

83-
define void @test_no_simplify2(%FILE* %fp, double %d) {
76+
define void @test_no_simplify2(ptr %fp, double %d) {
8477
; CHECK-LABEL: @test_no_simplify2(
85-
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_f, i32 0, i32 0
86-
call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt, double %d)
87-
; CHECK-NEXT: call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @percent_f, i32 0, i32 0), double %d)
78+
call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @percent_f, double %d)
79+
; CHECK-NEXT: call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr nonnull @percent_f, double %d)
8880
ret void
8981
; CHECK-NEXT: ret void
9082
}
9183

92-
define i32 @test_no_simplify3(%FILE* %fp) {
84+
define i32 @test_no_simplify3(ptr %fp) {
9385
; CHECK-LABEL: @test_no_simplify3(
94-
%fmt = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
95-
%1 = call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt)
96-
; CHECK-NEXT: call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0))
86+
%1 = call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @hello_world)
87+
; CHECK-NEXT: call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr nonnull @hello_world)
9788
ret i32 %1
9889
; CHECK-NEXT: ret i32 %1
9990
}
10091

10192
; Verify that a call with a format string containing just the %m directive
10293
; and no arguments is not simplified.
10394

104-
define void @test_no_simplify4(%FILE* %fp) {
95+
define void @test_no_simplify4(ptr %fp) {
10596
; CHECK-LABEL: @test_no_simplify4(
106-
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_m, i32 0, i32 0
107-
call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt)
108-
; CHECK-NEXT: call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @percent_m, i32 0, i32 0))
97+
call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @percent_m)
98+
; CHECK-NEXT: call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr nonnull @percent_m)
10999
ret void
110100
; CHECK-NEXT: ret void
111101
}

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

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
1717
@empty = constant [1 x i8] c"\00"
1818
; CHECK: [[$STR:@[a-z0-9]+]] = private unnamed_addr constant [12 x i8] c"hello world\00", align 1
1919

20-
declare i32 @printf(i8*, ...)
20+
declare i32 @printf(ptr, ...)
2121

2222
; Check printf("") -> noop.
2323

@@ -28,8 +28,7 @@ define void @test_simplify1() {
2828
; CHECK-IPRINTF-LABEL: @test_simplify1(
2929
; CHECK-IPRINTF-NEXT: ret void
3030
;
31-
%fmt = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
32-
call i32 (i8*, ...) @printf(i8* %fmt)
31+
call i32 (ptr, ...) @printf(ptr @empty)
3332
ret void
3433
}
3534

@@ -44,8 +43,7 @@ define void @test_simplify2() {
4443
; CHECK-IPRINTF-NEXT: [[PUTCHAR:%.*]] = call i32 @putchar(i32 104)
4544
; CHECK-IPRINTF-NEXT: ret void
4645
;
47-
%fmt = getelementptr [2 x i8], [2 x i8]* @h, i32 0, i32 0
48-
call i32 (i8*, ...) @printf(i8* %fmt)
46+
call i32 (ptr, ...) @printf(ptr @h)
4947
ret void
5048
}
5149

@@ -60,8 +58,7 @@ define void @test_simplify2b() {
6058
; CHECK-IPRINTF-NEXT: [[PUTCHAR:%.*]] = call i32 @putchar(i32 37)
6159
; CHECK-IPRINTF-NEXT: ret void
6260
;
63-
%fmt = getelementptr [3 x i8], [3 x i8]* @h2, i32 0, i32 0
64-
call i32 (i8*, ...) @printf(i8* %fmt)
61+
call i32 (ptr, ...) @printf(ptr @h2)
6562
ret void
6663
}
6764

@@ -74,24 +71,22 @@ define void @test_simplify3() {
7471
; CHECK-IPRINTF-NEXT: [[PUTCHAR:%.*]] = call i32 @putchar(i32 37)
7572
; CHECK-IPRINTF-NEXT: ret void
7673
;
77-
%fmt = getelementptr [2 x i8], [2 x i8]* @percent, i32 0, i32 0
78-
call i32 (i8*, ...) @printf(i8* %fmt)
74+
call i32 (ptr, ...) @printf(ptr @percent)
7975
ret void
8076
}
8177

8278
; Check printf("foo\n") -> puts("foo").
8379

8480
define void @test_simplify4() {
8581
; CHECK-LABEL: @test_simplify4(
86-
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i32 0, i32 0))
82+
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr nonnull @str)
8783
; CHECK-NEXT: ret void
8884
;
8985
; CHECK-IPRINTF-LABEL: @test_simplify4(
90-
; CHECK-IPRINTF-NEXT: [[PUTS:%.*]] = call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i32 0, i32 0))
86+
; CHECK-IPRINTF-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr nonnull @str)
9187
; CHECK-IPRINTF-NEXT: ret void
9288
;
93-
%fmt = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
94-
call i32 (i8*, ...) @printf(i8* %fmt)
89+
call i32 (ptr, ...) @printf(ptr @hello_world)
9590
ret void
9691
}
9792

@@ -106,81 +101,75 @@ define void @test_simplify5() {
106101
; CHECK-IPRINTF-NEXT: [[PUTCHAR:%.*]] = call i32 @putchar(i32 104)
107102
; CHECK-IPRINTF-NEXT: ret void
108103
;
109-
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_c, i32 0, i32 0
110-
call i32 (i8*, ...) @printf(i8* %fmt, i8 104)
104+
call i32 (ptr, ...) @printf(ptr @percent_c, i8 104)
111105
ret void
112106
}
113107

114108
; Check printf("%s\n", str) -> puts(str).
115109

116110
define void @test_simplify6() {
117111
; CHECK-LABEL: @test_simplify6(
118-
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0))
112+
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr nonnull @hello_world)
119113
; CHECK-NEXT: ret void
120114
;
121115
; CHECK-IPRINTF-LABEL: @test_simplify6(
122-
; CHECK-IPRINTF-NEXT: [[PUTS:%.*]] = call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0))
116+
; CHECK-IPRINTF-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr nonnull @hello_world)
123117
; CHECK-IPRINTF-NEXT: ret void
124118
;
125-
%fmt = getelementptr [4 x i8], [4 x i8]* @percent_s, i32 0, i32 0
126-
%str = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
127-
call i32 (i8*, ...) @printf(i8* %fmt, i8* %str)
119+
call i32 (ptr, ...) @printf(ptr @percent_s, ptr @hello_world)
128120
ret void
129121
}
130122

131123
; Check printf(format, ...) -> iprintf(format, ...) if no floating point.
132124

133125
define void @test_simplify7() {
134126
; CHECK-LABEL: @test_simplify7(
135-
; CHECK-NEXT: [[TMP1:%.*]] = call i32 (i8*, ...) @printf(i8* noundef nonnull dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @percent_d, i32 0, i32 0), i32 187)
127+
; CHECK-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @printf(ptr noundef nonnull @percent_d, i32 187)
136128
; CHECK-NEXT: ret void
137129
;
138130
; CHECK-IPRINTF-LABEL: @test_simplify7(
139-
; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (i8*, ...) @iprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @percent_d, i32 0, i32 0), i32 187)
131+
; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @iprintf(ptr nonnull @percent_d, i32 187)
140132
; CHECK-IPRINTF-NEXT: ret void
141133
;
142-
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_d, i32 0, i32 0
143-
call i32 (i8*, ...) @printf(i8* %fmt, i32 187)
134+
call i32 (ptr, ...) @printf(ptr @percent_d, i32 187)
144135
ret void
145136
}
146137

147138
define void @test_no_simplify1() {
148139
; CHECK-LABEL: @test_no_simplify1(
149-
; CHECK-NEXT: [[TMP1:%.*]] = call i32 (i8*, ...) @printf(i8* noundef nonnull dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @percent_f, i32 0, i32 0), double 1.870000e+00)
140+
; CHECK-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @printf(ptr noundef nonnull @percent_f, double 1.870000e+00)
150141
; CHECK-NEXT: ret void
151142
;
152143
; CHECK-IPRINTF-LABEL: @test_no_simplify1(
153-
; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (i8*, ...) @printf(i8* noundef nonnull dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @percent_f, i32 0, i32 0), double 1.870000e+00)
144+
; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @printf(ptr noundef nonnull @percent_f, double 1.870000e+00)
154145
; CHECK-IPRINTF-NEXT: ret void
155146
;
156-
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_f, i32 0, i32 0
157-
call i32 (i8*, ...) @printf(i8* %fmt, double 1.87)
147+
call i32 (ptr, ...) @printf(ptr @percent_f, double 1.87)
158148
ret void
159149
}
160150

161-
define void @test_no_simplify2(i8* %fmt, double %d) {
151+
define void @test_no_simplify2(ptr %fmt, double %d) {
162152
; CHECK-LABEL: @test_no_simplify2(
163-
; CHECK-NEXT: [[TMP1:%.*]] = call i32 (i8*, ...) @printf(i8* noundef nonnull dereferenceable(1) [[FMT:%.*]], double [[D:%.*]])
153+
; CHECK-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) [[FMT:%.*]], double [[D:%.*]])
164154
; CHECK-NEXT: ret void
165155
;
166156
; CHECK-IPRINTF-LABEL: @test_no_simplify2(
167-
; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (i8*, ...) @printf(i8* noundef nonnull dereferenceable(1) [[FMT:%.*]], double [[D:%.*]])
157+
; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) [[FMT:%.*]], double [[D:%.*]])
168158
; CHECK-IPRINTF-NEXT: ret void
169159
;
170-
call i32 (i8*, ...) @printf(i8* %fmt, double %d)
160+
call i32 (ptr, ...) @printf(ptr %fmt, double %d)
171161
ret void
172162
}
173163

174164
define i32 @test_no_simplify3() {
175165
; CHECK-LABEL: @test_no_simplify3(
176-
; CHECK-NEXT: [[RET:%.*]] = call i32 (i8*, ...) @printf(i8* noundef nonnull dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @h, i32 0, i32 0))
166+
; CHECK-NEXT: [[RET:%.*]] = call i32 (ptr, ...) @printf(ptr noundef nonnull @h)
177167
; CHECK-NEXT: ret i32 [[RET]]
178168
;
179169
; CHECK-IPRINTF-LABEL: @test_no_simplify3(
180-
; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (i8*, ...) @iprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @h, i32 0, i32 0))
170+
; CHECK-IPRINTF-NEXT: [[TMP1:%.*]] = call i32 (ptr, ...) @iprintf(ptr nonnull @h)
181171
; CHECK-IPRINTF-NEXT: ret i32 [[TMP1]]
182172
;
183-
%fmt = getelementptr [2 x i8], [2 x i8]* @h, i32 0, i32 0
184-
%ret = call i32 (i8*, ...) @printf(i8* %fmt)
173+
%ret = call i32 (ptr, ...) @printf(ptr @h)
185174
ret i32 %ret
186175
}

llvm/test/Transforms/InstCombine/printf-2.ll

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
1212
@charstr = constant [2 x i8] c"a\00"
1313
@empty = constant [1 x i8] c"\00"
1414

15-
declare i32 @printf(i8*, ...)
15+
declare i32 @printf(ptr, ...)
1616

1717
; Check simplification of printf with void return type.
1818

@@ -32,29 +32,25 @@ define void @test_simplify1() {
3232
; CHECK-NEXT: [[PUTCHAR:%.*]] = call i32 @putchar(i32 104)
3333
; CHECK-NEXT: ret void
3434
;
35-
%fmt = getelementptr [2 x i8], [2 x i8]* @h, i32 0, i32 0
36-
call i32 (i8*, ...) @printf(i8* %fmt)
35+
call i32 (ptr, ...) @printf(ptr @h)
3736
ret void
3837
}
3938

4039
define void @test_simplify2() {
4140
; CHECK-LABEL: @test_simplify2(
42-
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i32 0, i32 0))
41+
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr nonnull @str)
4342
; CHECK-NEXT: ret void
4443
;
45-
%fmt = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
46-
call i32 (i8*, ...) @printf(i8* %fmt)
44+
call i32 (ptr, ...) @printf(ptr @hello_world)
4745
ret void
4846
}
4947

5048
define void @test_simplify6() {
5149
; CHECK-LABEL: @test_simplify6(
52-
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0))
50+
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr nonnull @hello_world)
5351
; CHECK-NEXT: ret void
5452
;
55-
%fmt = getelementptr [4 x i8], [4 x i8]* @percent_s, i32 0, i32 0
56-
%str = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
57-
call i32 (i8*, ...) @printf(i8* %fmt, i8* %str)
53+
call i32 (ptr, ...) @printf(ptr @percent_s, ptr @hello_world)
5854
ret void
5955
}
6056

@@ -63,9 +59,7 @@ define void @test_simplify7() {
6359
; CHECK-NEXT: [[PUTCHAR:%.*]] = call i32 @putchar(i32 97)
6460
; CHECK-NEXT: ret void
6561
;
66-
%fmt = getelementptr [3 x i8], [3 x i8]* @format_str, i32 0, i32 0
67-
%str = getelementptr [2 x i8], [2 x i8]* @charstr, i32 0, i32 0
68-
call i32 (i8*, ...) @printf(i8* %fmt, i8* %str)
62+
call i32 (ptr, ...) @printf(ptr @format_str, ptr @charstr)
6963
ret void
7064
}
7165

@@ -75,22 +69,18 @@ define void @test_simplify8() {
7569
; CHECK-LABEL: @test_simplify8(
7670
; CHECK-NEXT: ret void
7771
;
78-
%fmt = getelementptr [3 x i8], [3 x i8]* @format_str, i32 0, i32 0
79-
%str = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
80-
call i32 (i8*, ...) @printf(i8* %fmt, i8* %str)
72+
call i32 (ptr, ...) @printf(ptr @format_str, ptr @empty)
8173
ret void
8274
}
8375

8476
; printf("%s", str"\n") --> puts(str)
8577

8678
define void @test_simplify9() {
8779
; CHECK-LABEL: @test_simplify9(
88-
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.1, i32 0, i32 0))
80+
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr nonnull @str.1)
8981
; CHECK-NEXT: ret void
9082
;
91-
%fmt = getelementptr [3 x i8], [3 x i8]* @format_str, i32 0, i32 0
92-
%str = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
93-
call i32 (i8*, ...) @printf(i8* %fmt, i8* %str)
83+
call i32 (ptr, ...) @printf(ptr @format_str, ptr @hello_world)
9484
ret void
9585
}
9686

@@ -101,16 +91,12 @@ define void @test_simplify9() {
10191
define void @test_simplify10() {
10292
; CHECK-LABEL: @test_simplify10(
10393
; CHECK-NEXT: [[PUTCHAR:%.*]] = call i32 @putchar(i32 97)
104-
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.2, i32 0, i32 0))
94+
; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr nonnull @str.2)
10595
; CHECK-NEXT: ret void
10696
;
107-
%fmt = getelementptr [3 x i8], [3 x i8]* @format_str, i32 0, i32 0
108-
%str1 = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
109-
call i32 (i8*, ...) @printf(i8* %fmt, i8* %str1, i32 42, double 0x40091EB860000000)
110-
%str2 = getelementptr [2 x i8], [2 x i8]* @charstr, i32 0, i32 0
111-
call i32 (i8*, ...) @printf(i8* %fmt, i8* %str2, i32 42, double 0x40091EB860000000)
112-
%str3 = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
113-
call i32 (i8*, ...) @printf(i8* %fmt, i8* %str3, i32 42, double 0x40091EB860000000)
97+
call i32 (ptr, ...) @printf(ptr @format_str, ptr @empty, i32 42, double 0x40091EB860000000)
98+
call i32 (ptr, ...) @printf(ptr @format_str, ptr @charstr, i32 42, double 0x40091EB860000000)
99+
call i32 (ptr, ...) @printf(ptr @format_str, ptr @hello_world, i32 42, double 0x40091EB860000000)
114100
ret void
115101
}
116102
;.

0 commit comments

Comments
 (0)