public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Comments in assember output
@ 2006-11-24 15:43 Artur Krzysztof Szostak
  2006-11-24 15:44 ` Andrew Haley
  0 siblings, 1 reply; 21+ messages in thread
From: Artur Krzysztof Szostak @ 2006-11-24 15:43 UTC (permalink / raw)
  To: gcc-help

Is there a way to make GCC output the source code comments or corresponding 
c++ source code that generated a set of assembler instructions in the .s 
files?
The only thing that seems to come close is the -fverbose-asm switch, but this 
does not give enough commentry for me to quickly and easily track down the 
corresponding source line in the c++ source code.

-- 

Artur Szostak

Tel. +27 21 650 3356
Mobile: +27 82 297 9502
Emails: artur@alice.phy.uct.ac.za  artursz@iafrica.com
AIM: artiblot
Skype: artiblot
Room: 4T6
Address:
R.W. James Building,
Rondebosch, 7701
Cape Town, South Africa

Physics Department
University of Cape Town

^ permalink raw reply	[flat|nested] 21+ messages in thread
* RE: Comments in assember output
@ 2006-12-01 21:33 John Yates
  2006-12-04  8:30 ` Fabian Cenedese
  0 siblings, 1 reply; 21+ messages in thread
From: John Yates @ 2006-12-01 21:33 UTC (permalink / raw)
  To: Fabian Cenedese, gcc-help

On Friday 2006-12-01 Fabian Cenedese wrote:

>                                           ... But when I tried it
> it didn't mix the lines, I just got (almost) all lines from the cpp
> source file and after that the assembler code.

I have seen this effect quite regularly.  I do not know this for a
fact but have always assumed that the incorporation of source code
into the assembly listing was a classic stream merge based on line
numbers.  This works okay as long as the generated code closely
parallels the source.  It also depends on what bits of intermediate
representation are allowed to claim source line correspondence.

The reason that I suggest this explanation is that the gcc behavior
seems very reminiscent of what I used to see for a while from the Apollo
compilers.  A classic example was an assignment within a loop with an
invariant RHS.  If the RHS required any expression evaluation and if
the instructions carrying out that evaluation was moved out of the
loop then all loop source lines up to and including that assignment
would be emitted ahead of the loop in the vicinity of the RHS evaluation.

I am writing from rather foggy memories but I believe that the fix was
to mark instructions with both a putative line number and a boolean
flag indicating whether or not the instruction corresponded to a
significant source side-effect.  The listing format included a source
line number as an end-of-line comment.  Thus a motioned expression
could still be traced back to a source line.  Source lines were merged
into the assembly file using the classic scheme alluded to above with
the following refinement.  When an assembly instruction included a source
line correlation higher than the most recently merged source line that
line number correlation was ignored unless either a) that instruction was
flagged as a significant side-effect or b) there was an uninterrupted run
of instructions with that same line number correlation ultimately leading
to an instruction that was flagged as a significant side-effect.

As I recall the motivation for making these changes was not more readable
assembly listing but a need for saner information in the debugger's pc
correlation table.

/john

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

end of thread, other threads:[~2006-12-04 10:44 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-24 15:43 Comments in assember output Artur Krzysztof Szostak
2006-11-24 15:44 ` Andrew Haley
2006-11-30 12:34   ` Artur Krzysztof Szostak
2006-11-30 15:20     ` Ian Lance Taylor
2006-11-30 15:30       ` Artur Krzysztof Szostak
2006-11-30 15:51         ` Ian Lance Taylor
2006-11-30 16:33           ` Artur Krzysztof Szostak
2006-11-30 16:46             ` malc
2006-11-30 17:02               ` Artur Krzysztof Szostak
2006-11-30 17:11                 ` Tony Wetmore
2006-11-30 17:14                   ` Ian Lance Taylor
2006-11-30 17:02             ` Tony Wetmore
2006-12-01 10:54               ` Fabian Cenedese
2006-12-01 11:03                 ` Andrew Haley
2006-12-01 11:17                   ` Fabian Cenedese
2006-12-01 11:22                     ` Andrew Haley
2006-12-01 12:22                       ` Fabian Cenedese
2006-12-01 13:54                       ` Fabian Cenedese
2006-12-01 21:33 John Yates
2006-12-04  8:30 ` Fabian Cenedese
2006-12-04 10:44   ` Andrew Haley

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