public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix unwind info with inline asm (PR middle-end/48597)
@ 2011-04-14 19:11 Jakub Jelinek
  2011-04-28 17:28 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2011-04-14 19:11 UTC (permalink / raw)
  To: gcc-patches

Hi!

   void
   foo (void)
   {
     register long s __asm ("r13");
     register long t __asm ("r14");
     register long u __asm ("r15");
     asm volatile ("xorq %%r12, %%r12" : : : "r12");
     asm volatile ("xorq %0, %0" : "=r" (s));
     asm volatile ("xorq %0, %0" : "=r" (t));
     asm volatile ("xorq %0, %0" : "=r" (u));
   }

has wrong unwind info on x86_64-linux with -O2, the problem is
that dwarf2_frame_debug isn't called on the inline asm which
clobbers registers which have queued register saves.
This leads to the queued register saves to be emitted only after
all the inline asms, while they need to be flushed before the first
inline asm that clobbers any of the registers.
In the originally reported problem, there was just one inline asm
early in the function and the bug was mitigated by the
http://gcc.gnu.org/ml/gcc-patches/2010-09/msg01557.html
patch.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk/4.6?

2011-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/48597
	* final.c (final_scan_insn): Call dwarf2out_frame_debug even for
	inline asm.

--- gcc/final.c.jj	2011-04-11 19:26:53.000000000 +0200
+++ gcc/final.c	2011-04-14 14:09:05.602402069 +0200
@@ -2313,6 +2313,9 @@ final_scan_insn (rtx insn, FILE *file, i
 	    location_t loc;
 	    expanded_location expanded;
 
+	    if (dwarf2out_do_frame ())
+	      dwarf2out_frame_debug (insn, false);
+
 	    /* There's no telling what that did to the condition codes.  */
 	    CC_STATUS_INIT;
 


	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix unwind info with inline asm (PR middle-end/48597)
  2011-04-14 19:11 [PATCH] Fix unwind info with inline asm (PR middle-end/48597) Jakub Jelinek
@ 2011-04-28 17:28 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2011-04-28 17:28 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

I think this could use a comment along the lines of "make sure we flush 
any queued register saves in case this clobbers affected registers".  OK 
with that change.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-28 16:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-14 19:11 [PATCH] Fix unwind info with inline asm (PR middle-end/48597) Jakub Jelinek
2011-04-28 17:28 ` Jason Merrill

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).