diff --git a/llvm/test/CodeGen/RISCV/rvv/rvv-stack-align.mir b/llvm/test/CodeGen/RISCV/rvv/rvv-stack-align.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/rvv-stack-align.mir @@ -0,0 +1,210 @@ +# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +# RUN: llc -mtriple riscv64 -mattr=+m,+experimental-v -start-before=prologepilog -o - \ +# RUN: -verify-machineinstrs %s | FileCheck %s +--- | + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64" + + declare void @extern(*) + + define void @rvv_stack_align8() { + ; CHECK-LABEL: rvv_stack_align8: + ; CHECK: # %bb.0: + ; CHECK-NEXT: addi sp, sp, -16 + ; CHECK-NEXT: .cfi_def_cfa_offset 16 + ; CHECK-NEXT: sd ra, 8(sp) # 8-byte Folded Spill + ; CHECK-NEXT: .cfi_offset ra, -8 + ; CHECK-NEXT: csrr a0, vlenb + ; CHECK-NEXT: slli a0, a0, 1 + ; CHECK-NEXT: sub sp, sp, a0 + ; CHECK-NEXT: addi a0, sp, 8 + ; CHECK-NEXT: call extern@plt + ; CHECK-NEXT: csrr a0, vlenb + ; CHECK-NEXT: slli a0, a0, 1 + ; CHECK-NEXT: add sp, sp, a0 + ; CHECK-NEXT: ld ra, 8(sp) # 8-byte Folded Reload + ; CHECK-NEXT: addi sp, sp, 16 + ; CHECK-NEXT: ret + %a = alloca , align 8 + call void @extern(* %a) + ret void + } + + ; FIXME: The alloca is not correctly aligned to 16 bytes. + + define void @rvv_stack_align16() { + ; CHECK-LABEL: rvv_stack_align16: + ; CHECK: # %bb.0: + ; CHECK-NEXT: addi sp, sp, -16 + ; CHECK-NEXT: .cfi_def_cfa_offset 16 + ; CHECK-NEXT: sd ra, 8(sp) # 8-byte Folded Spill + ; CHECK-NEXT: .cfi_offset ra, -8 + ; CHECK-NEXT: csrr a0, vlenb + ; CHECK-NEXT: slli a0, a0, 1 + ; CHECK-NEXT: sub sp, sp, a0 + ; CHECK-NEXT: addi a0, sp, 8 + ; CHECK-NEXT: call extern@plt + ; CHECK-NEXT: csrr a0, vlenb + ; CHECK-NEXT: slli a0, a0, 1 + ; CHECK-NEXT: add sp, sp, a0 + ; CHECK-NEXT: ld ra, 8(sp) # 8-byte Folded Reload + ; CHECK-NEXT: addi sp, sp, 16 + ; CHECK-NEXT: ret + %a = alloca , align 16 + call void @extern(* %a) + ret void + } + + ; FIXME: The alloca is not correctly aligned to 32 bytes. + + define void @rvv_stack_align32() { + ; CHECK-LABEL: rvv_stack_align32: + ; CHECK: # %bb.0: + ; CHECK-NEXT: addi sp, sp, -32 + ; CHECK-NEXT: .cfi_def_cfa_offset 32 + ; CHECK-NEXT: sd ra, 24(sp) # 8-byte Folded Spill + ; CHECK-NEXT: sd s0, 16(sp) # 8-byte Folded Spill + ; CHECK-NEXT: .cfi_offset ra, -8 + ; CHECK-NEXT: .cfi_offset s0, -16 + ; CHECK-NEXT: addi s0, sp, 32 + ; CHECK-NEXT: .cfi_def_cfa s0, 0 + ; CHECK-NEXT: csrr a0, vlenb + ; CHECK-NEXT: slli a0, a0, 1 + ; CHECK-NEXT: sub sp, sp, a0 + ; CHECK-NEXT: andi sp, sp, -32 + ; CHECK-NEXT: addi a0, sp, 16 + ; CHECK-NEXT: call extern@plt + ; CHECK-NEXT: addi sp, s0, -32 + ; CHECK-NEXT: ld s0, 16(sp) # 8-byte Folded Reload + ; CHECK-NEXT: ld ra, 24(sp) # 8-byte Folded Reload + ; CHECK-NEXT: addi sp, sp, 32 + ; CHECK-NEXT: ret + %a = alloca , align 32 + call void @extern(* %a) + ret void + } + +... +--- +name: rvv_stack_align8 +alignment: 4 +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 8 + adjustsStack: false + hasCalls: true + stackProtector: '' + maxCallFrameSize: 4294967295 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: a, type: default, offset: 0, size: 16, alignment: 8, + stack-id: scalable-vector, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0 (%ir-block.0): + ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2 + $x10 = ADDI %stack.0.a, 0 + PseudoCALL target-flags(riscv-plt) @extern, csr_ilp32_lp64, implicit-def dead $x1, implicit killed $x10, implicit-def $x2 + ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2 + PseudoRET + +... +--- +name: rvv_stack_align16 +alignment: 4 +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 16 + adjustsStack: false + hasCalls: true + stackProtector: '' + maxCallFrameSize: 4294967295 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: a, type: default, offset: 0, size: 16, alignment: 16, + stack-id: scalable-vector, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0 (%ir-block.0): + ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2 + $x10 = ADDI %stack.0.a, 0 + PseudoCALL target-flags(riscv-plt) @extern, csr_ilp32_lp64, implicit-def dead $x1, implicit killed $x10, implicit-def $x2 + ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2 + PseudoRET + +... +--- +name: rvv_stack_align32 +alignment: 4 +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 32 + adjustsStack: false + hasCalls: true + stackProtector: '' + maxCallFrameSize: 4294967295 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: a, type: default, offset: 0, size: 16, alignment: 32, + stack-id: scalable-vector, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: [] +debugValueSubstitutions: [] +constants: [] +machineFunctionInfo: {} +body: | + bb.0 (%ir-block.0): + ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2 + $x10 = ADDI %stack.0.a, 0 + PseudoCALL target-flags(riscv-plt) @extern, csr_ilp32_lp64, implicit-def dead $x1, implicit killed $x10, implicit-def $x2 + ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2 + PseudoRET + +...