svn commit: r252039 - in head/contrib: gcc llvm/lib/CodeGen

Dimitry Andric dim at FreeBSD.org
Thu Jun 20 18:25:11 UTC 2013


Author: dim
Date: Thu Jun 20 18:25:10 2013
New Revision: 252039
URL: http://svnweb.freebsd.org/changeset/base/252039

Log:
  Pull in r183984 from llvm trunk:
  
    Make PrologEpilogInserter save/restore all callee saved registers in
    functions which call __builtin_unwind_init()
  
    __builtin_unwind_init() is an undocumented gcc intrinsic which has
    this effect, and is used in libgcc_eh.
  
    Goes part of the way toward fixing PR8541.
  
  This obsoletes the ugly hack to libgcc's unwind code from r245272, and
  should also work for other arches, so revert the hack too.

Modified:
  head/contrib/gcc/unwind-dw2.c
  head/contrib/llvm/lib/CodeGen/PrologEpilogInserter.cpp

Modified: head/contrib/gcc/unwind-dw2.c
==============================================================================
--- head/contrib/gcc/unwind-dw2.c	Thu Jun 20 17:45:29 2013	(r252038)
+++ head/contrib/gcc/unwind-dw2.c	Thu Jun 20 18:25:10 2013	(r252039)
@@ -1438,17 +1438,6 @@ uw_init_context_1 (struct _Unwind_Contex
   context->ra = __builtin_extract_return_addr (outer_ra);
 }
 
-#if defined(__clang__) && defined(__amd64__)
-/* Some versions of clang don't save and restore all callee registers, if a
-   __builtin_eh_return() intrinsic is used in a function.  This is particularly
-   bad on amd64.  For now, use the following ugly hack to force it to assume
-   those registers are clobbered, when invoking __builtin_eh_return(), so it
-   will emit code to save and restore them.  */
-#define CLOBBER_REGS_HACK \
-  __asm __volatile(" " : : : "r15", "r14", "r13", "r12", "rbx", "rdx", "rax");
-#else
-#define CLOBBER_REGS_HACK
-#endif /* __clang__ */
 
 /* Install TARGET into CURRENT so that we can return to it.  This is a
    macro because __builtin_eh_return must be invoked in the context of
@@ -1459,7 +1448,6 @@ uw_init_context_1 (struct _Unwind_Contex
     {									 \
       long offset = uw_install_context_1 ((CURRENT), (TARGET));		 \
       void *handler = __builtin_frob_return_addr ((TARGET)->ra);	 \
-      CLOBBER_REGS_HACK							 \
       __builtin_eh_return (offset, handler);				 \
     }									 \
   while (0)

Modified: head/contrib/llvm/lib/CodeGen/PrologEpilogInserter.cpp
==============================================================================
--- head/contrib/llvm/lib/CodeGen/PrologEpilogInserter.cpp	Thu Jun 20 17:45:29 2013	(r252038)
+++ head/contrib/llvm/lib/CodeGen/PrologEpilogInserter.cpp	Thu Jun 20 18:25:10 2013	(r252039)
@@ -29,6 +29,7 @@
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/MachineLoopInfo.h"
+#include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/RegisterScavenging.h"
 #include "llvm/IR/InlineAsm.h"
@@ -214,7 +215,8 @@ void PEI::calculateCalleeSavedRegisters(
   std::vector<CalleeSavedInfo> CSI;
   for (unsigned i = 0; CSRegs[i]; ++i) {
     unsigned Reg = CSRegs[i];
-    if (F.getRegInfo().isPhysRegUsed(Reg)) {
+    // Functions which call __builtin_unwind_init get all their registers saved.
+    if (F.getRegInfo().isPhysRegUsed(Reg) || F.getMMI().callsUnwindInit()) {
       // If the reg is modified, save it!
       CSI.push_back(CalleeSavedInfo(Reg));
     }


More information about the svn-src-all mailing list