public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Daniel Santos <daniel.santos@pobox.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, JonY <10walls@gmail.com>
Subject: Re: [RFC] [PATCH v3 0/8] [i386] Use out-of-line stubs for ms_abi pro/epilogues
Date: Mon, 13 Mar 2017 18:40:00 -0000	[thread overview]
Message-ID: <6f0a90d1-1fbb-9ce8-1dea-9caa76fc994a@pobox.com> (raw)
In-Reply-To: <5b7e6964-3875-55c2-caea-a95f36a466bb@gmail.com>

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

  parent reply	other threads:[~2017-03-13 18:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07 18:34 Daniel Santos
2017-02-07 18:36 ` [PATCH 4/8] [i386] Modify ix86_save_reg to optionally omit stub-managed registers Daniel Santos
2017-02-07 18:36 ` [PATCH 2/8] [i386] Add option -moutline-msabi-xlogues Daniel Santos
2017-02-08 23:28   ` Bernhard Reutner-Fischer
2017-02-10  4:43     ` Daniel Santos
2017-02-10 16:54       ` Sandra Loosemore
2017-02-10 17:32         ` Daniel Santos
2017-04-01 22:37         ` Daniel Santos
2017-02-07 18:36 ` [PATCH 3/8] [i386] Adds class xlouge_layout and new fields to struct machine_function Daniel Santos
2017-02-07 18:37 ` [PATCH 7/8] [i386] Add msabi pro/epilogue stubs to libgcc Daniel Santos
2017-02-07 18:37 ` [PATCH 1/8] [i386] Minor refactoring Daniel Santos
2017-02-07 18:37 ` [PATCH 6/8] [i386] Add patterns and predicates foutline-msabi-xlouges Daniel Santos
2017-02-07 18:37 ` [PATCH 5/8] [i386] Modify ix86_compute_frame_layout for foutline-msabi-xlogues Daniel Santos
2017-02-10 10:32 ` [RFC] [PATCH v3 0/8] [i386] Use out-of-line stubs for ms_abi pro/epilogues Uros Bizjak
2017-02-10 11:34   ` JonY
2017-02-10 17:20     ` Daniel Santos
2017-02-11  0:30       ` JonY
2017-02-11  7:24         ` Daniel Santos
2017-03-13 18:40         ` Daniel Santos [this message]
2017-03-10  4:42     ` Daniel Santos
2017-03-30 17:55       ` Daniel Santos
2017-03-30 23:28         ` JonY
2017-02-10 17:55   ` Daniel Santos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f0a90d1-1fbb-9ce8-1dea-9caa76fc994a@pobox.com \
    --to=daniel.santos@pobox.com \
    --cc=10walls@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).