[llvm] r185235 - PPC: Ignore spill/restore requests for VRSAVE (except on Darwin)

Hal Finkel hfinkel at anl.gov
Fri Jun 28 15:29:57 PDT 2013


Author: hfinkel
Date: Fri Jun 28 17:29:56 2013
New Revision: 185235

URL: http://llvm.org/viewvc/llvm-project?rev=185235&view=rev
Log:
PPC: Ignore spill/restore requests for VRSAVE (except on Darwin)

This fixes PR16418, which reports that a function calling
__builtin_unwind_init() asserts. The cause is that this generates a
spill/restore for VRSAVE, and we support that only on Darwin (because VRSAVE is
only really used on Darwin).

The test case checks only that we don't crash. We can add correctness checks
once someone verifies what behavior the function is supposed to have.

Added:
    llvm/trunk/test/CodeGen/PowerPC/unwind-dw2.ll
Modified:
    llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp

Modified: llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp?rev=185235&r1=185234&r2=185235&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCFrameLowering.cpp Fri Jun 28 17:29:56 2013
@@ -1145,6 +1145,12 @@ PPCFrameLowering::spillCalleeSavedRegist
   
   for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
     unsigned Reg = CSI[i].getReg();
+    // Only Darwin actually uses the VRSAVE register, but it can still appear
+    // here if, for example, @llvm.eh.unwind.init() is used.  If we're not on
+    // Darwin, ignore it.
+    if (Reg == PPC::VRSAVE && !Subtarget.isDarwinABI())
+      continue;
+
     // CR2 through CR4 are the nonvolatile CR fields.
     bool IsCRField = PPC::CR2 <= Reg && Reg <= PPC::CR4;
 
@@ -1294,6 +1300,12 @@ PPCFrameLowering::restoreCalleeSavedRegi
   for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
     unsigned Reg = CSI[i].getReg();
 
+    // Only Darwin actually uses the VRSAVE register, but it can still appear
+    // here if, for example, @llvm.eh.unwind.init() is used.  If we're not on
+    // Darwin, ignore it.
+    if (Reg == PPC::VRSAVE && !Subtarget.isDarwinABI())
+      continue;
+
     if (Reg == PPC::CR2) {
       CR2Spilled = true;
       // The spill slot is associated only with CR2, which is the

Added: llvm/trunk/test/CodeGen/PowerPC/unwind-dw2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/unwind-dw2.ll?rev=185235&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/unwind-dw2.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/unwind-dw2.ll Fri Jun 28 17:29:56 2013
@@ -0,0 +1,15 @@
+; RUN: llc < %s
+target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
+target triple = "powerpc64-unknown-linux-gnu"
+
+; Function Attrs: nounwind
+define void @foo() #0 {
+entry:
+  call void @llvm.eh.unwind.init()
+  ret void
+}
+
+; Function Attrs: nounwind
+declare void @llvm.eh.unwind.init() #0
+
+attributes #0 = { nounwind }





More information about the llvm-commits mailing list