diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -2023,9 +2023,10 @@ // Set the 4th byte of the mandatory field. FirstHalfOfMandatoryField |= TracebackTable::IsFunctionNamePresentMask; - static_assert(XCOFF::AllocRegNo == 31, "Unexpected register usage!"); - if (MRI.isPhysRegUsed(Subtarget->isPPC64() ? PPC::X31 : PPC::R31, - /* SkipRegMaskTest */ true)) + const PPCRegisterInfo *RegInfo = + static_cast(Subtarget->getRegisterInfo()); + Register FrameReg = RegInfo->getFrameRegister(*MF); + if (FrameReg == (Subtarget->isPPC64() ? PPC::X31 : PPC::R31)) FirstHalfOfMandatoryField |= TracebackTable::IsAllocaUsedMask; const SmallVectorImpl &MustSaveCRs = FI->getMustSaveCRs(); diff --git a/llvm/test/CodeGen/PowerPC/aix-alloca-r31.ll b/llvm/test/CodeGen/PowerPC/aix-alloca-r31.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-alloca-r31.ll @@ -0,0 +1,96 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=+altivec -vec-extabi -xcoff-traceback-table=true < %s | \ +; RUN: FileCheck --check-prefix=CHECK-ASM32 %s + +; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=+altivec -vec-extabi -xcoff-traceback-table=true < %s | \ +; RUN: FileCheck --check-prefix=CHECK-ASM64 %s + +@var = local_unnamed_addr global i32 0 + +define i32 @varalloca() local_unnamed_addr { +; CHECK-ASM32-LABEL: varalloca: +; CHECK-ASM32: # %bb.0: # %entry +; CHECK-ASM32-NEXT: stw 31, -4(1) +; CHECK-ASM32-NEXT: stwu 1, -48(1) +; CHECK-ASM32-NEXT: lwz 3, L..C0(2) # @var +; CHECK-ASM32-NEXT: mr 31, 1 +; CHECK-ASM32-NEXT: addi 4, 31, 48 +; CHECK-ASM32-NEXT: lwz 3, 0(3) +; CHECK-ASM32-NEXT: addi 3, 3, 15 +; CHECK-ASM32-NEXT: rlwinm 3, 3, 0, 0, 27 +; CHECK-ASM32-NEXT: neg 3, 3 +; CHECK-ASM32-NEXT: stwux 4, 1, 3 +; CHECK-ASM32-NEXT: addi 3, 1, 32 +; CHECK-ASM32-NEXT: lwz 3, 0(3) +; CHECK-ASM32-NEXT: lwz 1, 0(1) +; CHECK-ASM32-NEXT: lwz 31, -4(1) +; CHECK-ASM32-NEXT: blr +; CHECK-ASM32-NEXT: L..varalloca0: +; CHECK-ASM32-NEXT: .vbyte 4, 0x00000000 # Traceback table begin +; CHECK-ASM32-NEXT: .byte 0x00 # Version = 0 +; CHECK-ASM32-NEXT: .byte 0x09 # Language = CPlusPlus +; CHECK-ASM32-NEXT: .byte 0x20 # -IsGlobaLinkage, -IsOutOfLineEpilogOrPrologue +; CHECK-ASM32-NEXT: # +HasTraceBackTableOffset, -IsInternalProcedure +; CHECK-ASM32-NEXT: # -HasControlledStorage, -IsTOCless +; CHECK-ASM32-NEXT: # -IsFloatingPointPresent +; CHECK-ASM32-NEXT: # -IsFloatingPointOperationLogOrAbortEnabled +; CHECK-ASM32-NEXT: .byte 0x60 # -IsInterruptHandler, +IsFunctionNamePresent, +IsAllocaUsed +; CHECK-ASM32-NEXT: # OnConditionDirective = 0, -IsCRSaved, -IsLRSaved +; CHECK-ASM32-NEXT: .byte 0x80 # +IsBackChainStored, -IsFixup, NumOfFPRsSaved = 0 +; CHECK-ASM32-NEXT: .byte 0x01 # -HasExtensionTable, -HasVectorInfo, NumOfGPRsSaved = 1 +; CHECK-ASM32-NEXT: .byte 0x00 # NumberOfFixedParms = 0 +; CHECK-ASM32-NEXT: .byte 0x01 # NumberOfFPParms = 0, +HasParmsOnStack +; CHECK-ASM32-NEXT: .vbyte 4, L..varalloca0-.varalloca # Function size +; CHECK-ASM32-NEXT: .vbyte 2, 0x0009 # Function name len = 9 +; CHECK-ASM32-NEXT: .byte "varalloca" # Function Name +; CHECK-ASM32-NEXT: .byte 0x1f # AllocaUsed +; CHECK-ASM32-NEXT: # -- End function +; +; CHECK-ASM64-LABEL: varalloca: +; CHECK-ASM64: # %bb.0: # %entry +; CHECK-ASM64-NEXT: std 31, -8(1) +; CHECK-ASM64-NEXT: stdu 1, -64(1) +; CHECK-ASM64-NEXT: ld 3, L..C0(2) # @var +; CHECK-ASM64-NEXT: mr 31, 1 +; CHECK-ASM64-NEXT: addi 4, 31, 64 +; CHECK-ASM64-NEXT: lwz 3, 0(3) +; CHECK-ASM64-NEXT: addi 3, 3, 15 +; CHECK-ASM64-NEXT: rldicl 3, 3, 60, 4 +; CHECK-ASM64-NEXT: rldicl 3, 3, 4, 31 +; CHECK-ASM64-NEXT: neg 3, 3 +; CHECK-ASM64-NEXT: stdux 4, 1, 3 +; CHECK-ASM64-NEXT: addi 3, 1, 48 +; CHECK-ASM64-NEXT: lwz 3, 0(3) +; CHECK-ASM64-NEXT: ld 1, 0(1) +; CHECK-ASM64-NEXT: ld 31, -8(1) +; CHECK-ASM64-NEXT: blr +; CHECK-ASM64-NEXT: L..varalloca0: +; CHECK-ASM64-NEXT: .vbyte 4, 0x00000000 # Traceback table begin +; CHECK-ASM64-NEXT: .byte 0x00 # Version = 0 +; CHECK-ASM64-NEXT: .byte 0x09 # Language = CPlusPlus +; CHECK-ASM64-NEXT: .byte 0x20 # -IsGlobaLinkage, -IsOutOfLineEpilogOrPrologue +; CHECK-ASM64-NEXT: # +HasTraceBackTableOffset, -IsInternalProcedure +; CHECK-ASM64-NEXT: # -HasControlledStorage, -IsTOCless +; CHECK-ASM64-NEXT: # -IsFloatingPointPresent +; CHECK-ASM64-NEXT: # -IsFloatingPointOperationLogOrAbortEnabled +; CHECK-ASM64-NEXT: .byte 0x60 # -IsInterruptHandler, +IsFunctionNamePresent, +IsAllocaUsed +; CHECK-ASM64-NEXT: # OnConditionDirective = 0, -IsCRSaved, -IsLRSaved +; CHECK-ASM64-NEXT: .byte 0x80 # +IsBackChainStored, -IsFixup, NumOfFPRsSaved = 0 +; CHECK-ASM64-NEXT: .byte 0x01 # -HasExtensionTable, -HasVectorInfo, NumOfGPRsSaved = 1 +; CHECK-ASM64-NEXT: .byte 0x00 # NumberOfFixedParms = 0 +; CHECK-ASM64-NEXT: .byte 0x01 # NumberOfFPParms = 0, +HasParmsOnStack +; CHECK-ASM64-NEXT: .vbyte 4, L..varalloca0-.varalloca # Function size +; CHECK-ASM64-NEXT: .vbyte 2, 0x0009 # Function name len = 9 +; CHECK-ASM64-NEXT: .byte "varalloca" # Function Name +; CHECK-ASM64-NEXT: .byte 0x1f # AllocaUsed +; CHECK-ASM64-NEXT: # -- End function +entry: + %0 = load i32, i32* @var + %1 = alloca i8, i32 %0 + %2 = bitcast i8* %1 to i32* + %3 = load i32, i32* %2 + ret i32 %3 +} + diff --git a/llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll b/llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll --- a/llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll +++ b/llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll @@ -44,7 +44,7 @@ ; COMMON-NEXT: # -HasControlledStorage, -IsTOCless ; COMMON-NEXT: # +IsFloatingPointPresent ; COMMON-NEXT: # -IsFloatingPointOperationLogOrAbortEnabled -; COMMON-NEXT: .byte 0x60 # -IsInterruptHandler, +IsFunctionNamePresent, +IsAllocaUsed +; COMMON-NEXT: .byte 0x40 # -IsInterruptHandler, +IsFunctionNamePresent, -IsAllocaUsed ; COMMON-NEXT: # OnConditionDirective = 0, -IsCRSaved, -IsLRSaved ; COMMON-NEXT: .byte 0x85 # +IsBackChainStored, -IsFixup, NumOfFPRsSaved = 5 ; COMMON-NEXT: .byte 0x04 # -HasExtensionTable, -HasVectorInfo, NumOfGPRsSaved = 4 @@ -54,7 +54,6 @@ ; CHECK-FUNC-NEXT: .vbyte 4, L..bar0-.bar[PR] # Function size ; COMMON-NEXT: .vbyte 2, 0x0003 # Function name len = 3 ; COMMON-NEXT: .byte "bar" # Function Name -; COMMON-NEXT: .byte 0x1f # AllocaUsed ; COMMON-NEXT: # -- End function ; COMMON: L..foov0: