@@ -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
14
14
@percent_s = constant [3 x i8 ] c "%s\00 "
15
15
@percent_m = constant [3 x i8 ] c "%m\00 "
16
16
17
- declare i32 @fprintf (%FILE* , i8* , ...)
17
+ declare i32 @fprintf (ptr , ptr , ...)
18
18
19
19
; Check fprintf(fp, "foo") -> fwrite("foo", 3, 1, fp).
20
20
21
- define void @test_simplify1 (%FILE* %fp ) {
21
+ define void @test_simplify1 (ptr %fp ) {
22
22
; 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)
26
25
ret void
27
26
; CHECK-NEXT: ret void
28
27
}
29
28
30
29
; Check fprintf(fp, "%c", chr) -> fputc(chr, fp).
31
30
32
- define void @test_simplify2 (%FILE* %fp ) {
31
+ define void @test_simplify2 (ptr %fp ) {
33
32
; 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)
37
35
ret void
38
36
; CHECK-NEXT: ret void
39
37
}
40
38
41
39
; Check fprintf(fp, "%s", str) -> fputs(str, fp).
42
40
; NOTE: The fputs simplifier simplifies this further to fwrite.
43
41
44
- define void @test_simplify3 (%FILE* %fp ) {
42
+ define void @test_simplify3 (ptr %fp ) {
45
43
; 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)
50
46
ret void
51
47
; CHECK-NEXT: ret void
52
48
}
53
49
54
50
; Check fprintf(fp, fmt, ...) -> fiprintf(fp, fmt, ...) if no floating point.
55
51
56
- define void @test_simplify4 (%FILE* %fp ) {
52
+ define void @test_simplify4 (ptr %fp ) {
57
53
; 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)
61
56
ret void
62
57
; CHECK-IPRINTF-NEXT: ret void
63
58
}
64
59
65
- define void @test_simplify5 (%FILE* %fp ) {
60
+ define void @test_simplify5 (ptr %fp ) {
66
61
; 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"() ]
70
64
ret void
71
65
; CHECK-NEXT: ret void
72
66
}
73
67
74
- define void @test_no_simplify1 (%FILE* %fp ) {
68
+ define void @test_no_simplify1 (ptr %fp ) {
75
69
; 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)
79
72
ret void
80
73
; CHECK-IPRINTF-NEXT: ret void
81
74
}
82
75
83
- define void @test_no_simplify2 (%FILE* %fp , double %d ) {
76
+ define void @test_no_simplify2 (ptr %fp , double %d ) {
84
77
; 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)
88
80
ret void
89
81
; CHECK-NEXT: ret void
90
82
}
91
83
92
- define i32 @test_no_simplify3 (%FILE* %fp ) {
84
+ define i32 @test_no_simplify3 (ptr %fp ) {
93
85
; 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)
97
88
ret i32 %1
98
89
; CHECK-NEXT: ret i32 %1
99
90
}
100
91
101
92
; Verify that a call with a format string containing just the %m directive
102
93
; and no arguments is not simplified.
103
94
104
- define void @test_no_simplify4 (%FILE* %fp ) {
95
+ define void @test_no_simplify4 (ptr %fp ) {
105
96
; 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)
109
99
ret void
110
100
; CHECK-NEXT: ret void
111
101
}
0 commit comments