Files
clang-p2996/llvm/test/CodeGen/PowerPC/byval.ll
Stefan Pintilie 585c85abe5 [PowerPC] Fix lowering of byval parameters for sizes greater than 8 bytes.
To store a byval parameter the existing code would store as many 8 byte elements
as was required to store the full size of the byval parameter.
For example, a paramter of size 16 would store two element of 8 bytes.
A paramter of size 12 would also store two elements of 8 bytes.
This would sometimes store too many bytes as the size of the paramter is not
always a factor of 8.

This patch fixes that issue and now byval paramters are stored with the correct
number of bytes.

Reviewed By: nemanjai, #powerpc, quinnp, amyk

Differential Revision: https://reviews.llvm.org/D121430
2022-03-31 15:12:46 -05:00

42 lines
1.2 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -verify-machineinstrs < %s | FileCheck %s
target datalayout = "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512"
target triple = "powerpc64le-unknown-linux-gnu"
%struct = type { [4 x i32], [20 x i8] }
declare dso_local i32 @foo1(%struct* byval(%struct) %var)
declare dso_local void @foo(%struct* %var)
; check that 36bytes byval parameter is passed all in registers.
define dso_local i32 @bar() {
; CHECK-LABEL: bar:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: mflr 0
; CHECK-NEXT: std 0, 16(1)
; CHECK-NEXT: stdu 1, -80(1)
; CHECK-NEXT: .cfi_def_cfa_offset 80
; CHECK-NEXT: .cfi_offset lr, 16
; CHECK-NEXT: addi 3, 1, 40
; CHECK-NEXT: bl foo
; CHECK-NEXT: nop
; CHECK-NEXT: lwz 7, 72(1)
; CHECK-NEXT: ld 6, 64(1)
; CHECK-NEXT: ld 5, 56(1)
; CHECK-NEXT: ld 4, 48(1)
; CHECK-NEXT: ld 3, 40(1)
; CHECK-NEXT: bl foo1
; CHECK-NEXT: nop
; CHECK-NEXT: addi 1, 1, 80
; CHECK-NEXT: ld 0, 16(1)
; CHECK-NEXT: mtlr 0
; CHECK-NEXT: blr
entry:
%x = alloca %struct, align 4
call void @foo(%struct* %x)
%r = call i32 @foo1(%struct* byval(%struct) %x)
ret i32 %r
}