Andrew Savonichev c65b4d64d4 [SelectionDAG] Do not second-guess alignment for alloca
Alignment of an alloca in IR can be lower than the preferred alignment
on purpose, but this override essentially treats the preferred
alignment as the minimum alignment.

The patch changes this behavior to always use the specified
alignment. If alignment is not set explicitly in LLVM IR, it is set to
DL.getPrefTypeAlign(Ty) in computeAllocaDefaultAlign.

Tests are changed as well: explicit alignment is increased to match
the preferred alignment if it changes output, or omitted when it is
hard to determine the right value (e.g. for pointers, some structs, or
weird types).

Differential Revision: https://reviews.llvm.org/D135462
2023-02-09 18:45:20 +03: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(ptr byval(%struct) %var)
declare dso_local void @foo(ptr %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: stdu 1, -80(1)
; CHECK-NEXT: std 0, 96(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 8
call void @foo(ptr %x)
%r = call i32 @foo1(ptr byval(%struct) %x)
ret i32 %r
}