forked from OSchip/llvm-project
65 lines
2.1 KiB
LLVM
65 lines
2.1 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
|
|
; RUN: opt -S -argpromotion < %s | FileCheck %s
|
|
|
|
; Test argument promotion involving bitcasts.
|
|
|
|
%opaque = type opaque
|
|
|
|
define internal i32 @callee_basic(i8* %p) {
|
|
; CHECK-LABEL: define {{[^@]+}}@callee_basic
|
|
; CHECK-SAME: (i8* [[P:%.*]]) {
|
|
; CHECK-NEXT: [[P_32:%.*]] = bitcast i8* [[P]] to i32*
|
|
; CHECK-NEXT: [[X:%.*]] = load i32, i32* [[P_32]], align 4
|
|
; CHECK-NEXT: [[P1:%.*]] = getelementptr i8, i8* [[P]], i64 4
|
|
; CHECK-NEXT: [[P1_32:%.*]] = bitcast i8* [[P1]] to i32*
|
|
; CHECK-NEXT: [[Y:%.*]] = load i32, i32* [[P1_32]], align 4
|
|
; CHECK-NEXT: [[Z:%.*]] = add i32 [[X]], [[Y]]
|
|
; CHECK-NEXT: ret i32 [[Z]]
|
|
;
|
|
%p.32 = bitcast i8* %p to i32*
|
|
%x = load i32, i32* %p.32
|
|
%p1 = getelementptr i8, i8* %p, i64 4
|
|
%p1.32 = bitcast i8* %p1 to i32*
|
|
%y = load i32, i32* %p1.32
|
|
%z = add i32 %x, %y
|
|
ret i32 %z
|
|
}
|
|
|
|
define void @caller_basic(i8* %p) {
|
|
; CHECK-LABEL: define {{[^@]+}}@caller_basic
|
|
; CHECK-SAME: (i8* [[P:%.*]]) {
|
|
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @callee_basic(i8* [[P]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call i32 @callee_basic(i8* %p)
|
|
ret void
|
|
}
|
|
|
|
define internal i32 @callee_opaque(%opaque* %p) {
|
|
; CHECK-LABEL: define {{[^@]+}}@callee_opaque
|
|
; CHECK-SAME: (%opaque* [[P:%.*]]) {
|
|
; CHECK-NEXT: [[P_32:%.*]] = bitcast %opaque* [[P]] to i32*
|
|
; CHECK-NEXT: [[X:%.*]] = load i32, i32* [[P_32]], align 4
|
|
; CHECK-NEXT: [[P1_32:%.*]] = getelementptr i32, i32* [[P_32]], i64 1
|
|
; CHECK-NEXT: [[Y:%.*]] = load i32, i32* [[P1_32]], align 4
|
|
; CHECK-NEXT: [[Z:%.*]] = add i32 [[X]], [[Y]]
|
|
; CHECK-NEXT: ret i32 [[Z]]
|
|
;
|
|
%p.32 = bitcast %opaque* %p to i32*
|
|
%x = load i32, i32* %p.32
|
|
%p1.32 = getelementptr i32, i32* %p.32, i64 1
|
|
%y = load i32, i32* %p1.32
|
|
%z = add i32 %x, %y
|
|
ret i32 %z
|
|
}
|
|
|
|
define void @caller_opaque(%opaque* %p) {
|
|
; CHECK-LABEL: define {{[^@]+}}@caller_opaque
|
|
; CHECK-SAME: (%opaque* [[P:%.*]]) {
|
|
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @callee_opaque(%opaque* [[P]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call i32 @callee_opaque(%opaque* %p)
|
|
ret void
|
|
}
|