[RFC] [PATCH v3 0/8] [i386] Use out-of-line stubs for ms_abi pro/epilogues

Daniel Santos daniel.santos@pobox.com
Mon Mar 13 18:40:00 GMT 2017


Uros,
Testing on Cygwin only turns out to be a nightmare, but I've finally 
gotten some test results that I'm calling "clean enough".  I have only 
done 64-bit Cygwin thus far, (still need 32-bit Cygwin as well as 32/64 
MinGW), but I've hit a snag.  The first patch set ("Use aligned SSE movs 
for re-aligned MS ABI pro/epilogues" -- 
https://gcc.gnu.org/ml/gcc-patches/2016-12/msg01859.html) modifies how 
we select a base register and offset for accessing the stack. The test 
gcc.target/x86_64/abi/callabi/vaarg-5a.c uses a realigned stack pointer 
in a cross-abi case that triggers an internal compiler error at 
config/i386/winnt.c:1132 where i386_pe_seh_unwind_emit() doesn't like 
REG_CFA_EXPRESSION in the notes. This is the snippet:

   for (note = REG_NOTES (insn); note ; note = XEXP (note,  1))
       {
         switch (REG_NOTE_KIND (note))
           {
           case REG_FRAME_RELATED_EXPR:
             pat = XEXP (note, 0);
             goto found;
   
           case REG_CFA_DEF_CFA:
           case REG_CFA_EXPRESSION:
             /* Only emitted with DRAP, which we disable.  */
             gcc_unreachable ();
             break;


This is the chunk that introduces this new behavior:

@@ -12824,6 +12878,13 @@ ix86_emit_save_reg_using_mov (machine_mode mode, unsigned int regno,
         }
      }
  
+  else if (base == stack_pointer_rtx && m->fs.sp_realigned
+          && cfa_offset >= m->fs.sp_realigned_offset)
+    {
+      gcc_checking_assert (stack_realign_fp);
+      add_reg_note (insn, REG_CFA_EXPRESSION, gen_rtx_SET (mem, reg));
+    }
+
    /* The memory may not be relative to the current CFA register,
       which means that we may need to generate a new pattern for
       use by the unwind info.  */

And this is a sample of pre- and post-patch in pro_and_epilogue:

RTL pre-patch:

(insn/f 41 40 42 2 (set (mem/c:V4SF (plus:DI (reg/f:DI 6 bp)
                 (const_int -160 [0xffffffffffffff60])) [6  S16 A64])
         (reg:V4SF 27 xmm6)) "/c/Users/daniel/proj/sys/gcc/github/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5b.c":29 -1
      (nil))


RTL post-patch:

(insn/f 41 40 42 2 (set (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
                 (const_int 48 [0x30])) [6  S16 A128])
         (reg:V4SF 27 xmm6)) "/c/Users/daniel/proj/sys/gcc/github/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5b.c":29 -1
      (expr_list:REG_CFA_EXPRESSION (set (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
                     (const_int 48 [0x30])) [6  S16 A128])
             (reg:V4SF 27 xmm6))
         (nil)))


I haven't learned much of the dwarf code so I can't fully appreciate the 
function of all of these notes, but if we're using the SP should I just 
omit the note and let dwarf intuit the insn? The test in 
i386_pe_seh_unwind_emit() presumes that if we're using 
REG_CFA_EXPRESSION then we've used DRAP, but that isn't the case after 
this patch. Can you please advise on the correct solution?  My current 
guess is to just remove the above chunk (or at least remove the note).

Also of note, I need to do more analysis on why my tests did not expose 
this flaw, since va args is something that it tests.

Thanks!
Daniel



More information about the Gcc-patches mailing list