Skip to content

Commit 8af8119

Browse files
committed
[ArgPromotion] Add test with bitcasts (NFC)
Argument promotion currently doesn't handle these.
1 parent 36c36c1 commit 8af8119

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2+
; RUN: opt -S -argpromotion < %s | FileCheck %s
3+
4+
; Test argument promotion involving bitcasts.
5+
6+
%opaque = type opaque
7+
8+
define internal i32 @callee_basic(i8* %p) {
9+
; CHECK-LABEL: define {{[^@]+}}@callee_basic
10+
; CHECK-SAME: (i8* [[P:%.*]]) {
11+
; CHECK-NEXT: [[P_32:%.*]] = bitcast i8* [[P]] to i32*
12+
; CHECK-NEXT: [[X:%.*]] = load i32, i32* [[P_32]], align 4
13+
; CHECK-NEXT: [[P1:%.*]] = getelementptr i8, i8* [[P]], i64 4
14+
; CHECK-NEXT: [[P1_32:%.*]] = bitcast i8* [[P1]] to i32*
15+
; CHECK-NEXT: [[Y:%.*]] = load i32, i32* [[P1_32]], align 4
16+
; CHECK-NEXT: [[Z:%.*]] = add i32 [[X]], [[Y]]
17+
; CHECK-NEXT: ret i32 [[Z]]
18+
;
19+
%p.32 = bitcast i8* %p to i32*
20+
%x = load i32, i32* %p.32
21+
%p1 = getelementptr i8, i8* %p, i64 4
22+
%p1.32 = bitcast i8* %p1 to i32*
23+
%y = load i32, i32* %p1.32
24+
%z = add i32 %x, %y
25+
ret i32 %z
26+
}
27+
28+
define void @caller_basic(i8* %p) {
29+
; CHECK-LABEL: define {{[^@]+}}@caller_basic
30+
; CHECK-SAME: (i8* [[P:%.*]]) {
31+
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @callee_basic(i8* [[P]])
32+
; CHECK-NEXT: ret void
33+
;
34+
call i32 @callee_basic(i8* %p)
35+
ret void
36+
}
37+
38+
define internal i32 @callee_opaque(%opaque* %p) {
39+
; CHECK-LABEL: define {{[^@]+}}@callee_opaque
40+
; CHECK-SAME: (%opaque* [[P:%.*]]) {
41+
; CHECK-NEXT: [[P_32:%.*]] = bitcast %opaque* [[P]] to i32*
42+
; CHECK-NEXT: [[X:%.*]] = load i32, i32* [[P_32]], align 4
43+
; CHECK-NEXT: [[P1_32:%.*]] = getelementptr i32, i32* [[P_32]], i64 1
44+
; CHECK-NEXT: [[Y:%.*]] = load i32, i32* [[P1_32]], align 4
45+
; CHECK-NEXT: [[Z:%.*]] = add i32 [[X]], [[Y]]
46+
; CHECK-NEXT: ret i32 [[Z]]
47+
;
48+
%p.32 = bitcast %opaque* %p to i32*
49+
%x = load i32, i32* %p.32
50+
%p1.32 = getelementptr i32, i32* %p.32, i64 1
51+
%y = load i32, i32* %p1.32
52+
%z = add i32 %x, %y
53+
ret i32 %z
54+
}
55+
56+
define void @caller_opaque(%opaque* %p) {
57+
; CHECK-LABEL: define {{[^@]+}}@caller_opaque
58+
; CHECK-SAME: (%opaque* [[P:%.*]]) {
59+
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @callee_opaque(%opaque* [[P]])
60+
; CHECK-NEXT: ret void
61+
;
62+
call i32 @callee_opaque(%opaque* %p)
63+
ret void
64+
}

0 commit comments

Comments
 (0)