On subtargets that have a red zone, we will copy the stack pointer to the base pointer in the prologue prior to updating the stack pointer. There are no other updates to the base pointer after that. This suggests that we should be able to restore the stack pointer from the base pointer rather than loading it from the back chain or adding the frame size back to either the stack pointer or the frame pointer. This came about because functions that call setjmp need to restore the SP from the FP because the back chain might have been clobbered (see https://reviews.llvm.org/D92906). However, if the stack is realigned, the restored SP might be incorrect (which is what caused the failures in the two ASan test cases). This patch was tested quite extensivelly both with sanitizer runtimes and general code. Differential revision: https://reviews.llvm.org/D93327
43 lines
1.4 KiB
LLVM
43 lines
1.4 KiB
LLVM
; RUN: llc -mcpu=pwr7 -mattr=-altivec -verify-machineinstrs \
|
|
; RUN: -mtriple=powerpc-unknown-aix < %s | FileCheck %s --check-prefix 32BIT
|
|
|
|
; RUN: llc -mcpu=pwr7 -mattr=-altivec -verify-machineinstrs \
|
|
; RUN: -mtriple=powerpc64-unknown-aix < %s | FileCheck %s --check-prefix 64BIT
|
|
|
|
; Use an overaligned buffer to force base-pointer usage. Test verifies:
|
|
; - base pointer register (r30) is saved/defined/restored.
|
|
; - stack frame is allocated with correct alignment.
|
|
; - Address of %AlignedBuffer is calculated based off offset from the stack
|
|
; pointer.
|
|
|
|
define float @caller(float %f) {
|
|
%AlignedBuffer = alloca [32 x i32], align 32
|
|
%Pointer = getelementptr inbounds [32 x i32], [32 x i32]* %AlignedBuffer, i64 0, i64 0
|
|
call void @callee(i32* %Pointer)
|
|
ret float %f
|
|
}
|
|
|
|
declare void @callee(i32*)
|
|
|
|
; 32BIT-LABEL: .caller:
|
|
; 32BIT: stw 30, -16(1)
|
|
; 32BIT: mr 30, 1
|
|
; 32BIT: clrlwi 0, 1, 27
|
|
; 32BIT: subfic 0, 0, -224
|
|
; 32BIT: stwux 1, 1, 0
|
|
; 32BIT: addi 3, 1, 64
|
|
; 32BIT: bl .callee
|
|
; 32BIT: mr 1, 30
|
|
; 32BIT: lwz 30, -16(1)
|
|
|
|
; 64BIT-LABEL: .caller:
|
|
; 64BIT: std 30, -24(1)
|
|
; 64BIT: mr 30, 1
|
|
; 64BIT: clrldi 0, 1, 59
|
|
; 64BIT: subfic 0, 0, -288
|
|
; 64BIT: stdux 1, 1, 0
|
|
; 64BIT: addi 3, 1, 128
|
|
; 64BIT: bl .callee
|
|
; 64BIT: mr 1, 30
|
|
; 64BIT: ld 30, -24(1)
|