[llvm-commits] [PATCH] Remove VRSAVE processing for PowerPC SVR4 ABIs

Roman Divacky rdivacky at freebsd.org
Wed Oct 10 13:12:49 PDT 2012


Add a comment about the darwin bug and then it's ok to commit imho.

On Wed, Oct 10, 2012 at 12:32:03PM -0500, William J. Schmidt wrote:
> The PowerPC VRSAVE register has been somewhat of an odd beast since the
> Altivec extensions were introduced.  Its use is optional, and allows the
> compiler to communicate to the operating system which vector registers
> should be saved and restored during a context switch.  In practice, this
> information is ignored by the various operating systems using the SVR4
> ABI; the kernel saves and restores the entire register state.  Setting
> the VRSAVE register is no longer performed by the AIX XL compilers, the
> IBM i compilers, or by GCC on Power Linux systems.  It seems best to
> avoid this logic within LLVM as well.
> 
> This patch avoids generating code to update and restore VRSAVE for the
> PowerPC SVR4 ABIs (32- and 64-bit).  The code remains in place for the
> Darwin ABI.
> 
> Side note: The VRSAVE logic contains a bug that may need to be addressed
> for users of the Darwin ABI.  The code currently saves the original
> state of VRSAVE in a GPR that persists for the lifetime of the function,
> and is used to restore the VRSAVE contents when the function returns.
> There is a later optimization that removes the prolog/epilog code for
> updating VRSAVE when it provably does not change within the body of the
> function (though it might change temporarily during a function call).
> The removal of the code results in a compile failure at -O0 when the
> function contains a function call, as the GPR containing original VRSAVE
> contents is spilled and reloaded around the call.  Without the prolog
> code, the spill instruction refers to an undefined register.
> 
> The attached patch has been tested with no new regressions.  Ok to
> commit?
> 
> Thanks,
> Bill
> -- 
> Bill Schmidt, Ph.D.
> IBM Advance Toolchain for PowerLinux
> IBM Linux Technology Center
> wschmidt at us.ibm.com
> wschmidt at linux.vnet.ibm.com
> 
> 
> 
> 
> 

> Index: test/CodeGen/PowerPC/novrsave.ll
> ===================================================================
> --- test/CodeGen/PowerPC/novrsave.ll	(revision 0)
> +++ test/CodeGen/PowerPC/novrsave.ll	(revision 0)
> @@ -0,0 +1,15 @@
> +; RUN: llc -O0 -mtriple=powerpc-unknown-linux-gnu   < %s | FileCheck %s
> +; RUN: llc -O0 -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s
> +
> +; This verifies that the code to update VRSAVE has been removed for SVR4.
> +
> +define <4 x float> @bar(<4 x float> %v) nounwind {
> +entry:
> +  %v.addr = alloca <4 x float>, align 16
> +  store <4 x float> %v, <4 x float>* %v.addr, align 16
> +  %0 = load <4 x float>* %v.addr, align 16
> +  ret <4 x float> %0
> +}
> +
> +; CHECK-NOT: mfspr
> +; CHECK-NOT: mtspr
> Index: lib/Target/PowerPC/PPCFrameLowering.cpp
> ===================================================================
> --- lib/Target/PowerPC/PPCFrameLowering.cpp	(revision 165328)
> +++ lib/Target/PowerPC/PPCFrameLowering.cpp	(working copy)
> @@ -282,12 +282,13 @@ void PPCFrameLowering::emitPrologue(MachineFunctio
>  
>    // Scan the prolog, looking for an UPDATE_VRSAVE instruction.  If we find it,
>    // process it.
> -  for (unsigned i = 0; MBBI != MBB.end(); ++i, ++MBBI) {
> -    if (MBBI->getOpcode() == PPC::UPDATE_VRSAVE) {
> -      HandleVRSaveUpdate(MBBI, TII);
> -      break;
> +  if (!Subtarget.isSVR4ABI())
> +    for (unsigned i = 0; MBBI != MBB.end(); ++i, ++MBBI) {
> +      if (MBBI->getOpcode() == PPC::UPDATE_VRSAVE) {
> +        HandleVRSaveUpdate(MBBI, TII);
> +        break;
> +      }
>      }
> -  }
>  
>    // Move MBBI back to the beginning of the function.
>    MBBI = MBB.begin();
> Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp
> ===================================================================
> --- lib/Target/PowerPC/PPCISelDAGToDAG.cpp	(revision 165328)
> +++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp	(working copy)
> @@ -53,7 +53,9 @@ namespace {
>        GlobalBaseReg = 0;
>        SelectionDAGISel::runOnMachineFunction(MF);
>  
> -      InsertVRSaveCode(MF);
> +      if (!PPCSubTarget.isSVR4ABI())
> +        InsertVRSaveCode(MF);
> +
>        return true;
>      }
>  

> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list