« Return to Thread: Comments in assember output

Re: Comments in assember output

by Tony Wetmore :: Rate this Message:

Reply to Author | View in Thread

Artur,

I just tried playing around with this, and it appears the the "-S" flag
is interfering.  Perhaps by stopping the compilation process in that
way, it prevents the generation of the "listing file".

I tried compiling your example function as follows:

   gcc -c -g -O3 -Wa,-adhls=func.list func.c

And got the following output (in func.list):

    1                            .file   "func.c"
    4                            .text
    5                    Ltext0:
   28                            .p2align 4,,15
   32                    .globl _func
   34                    _func:
    1:func.c        **** float func( float a, float b )
    2:func.c        **** {
   36                    LM1:
   37 0000 55                    pushl   %ebp
   38 0001 89E5                  movl    %esp, %ebp
   40                    LM2:
   41 0003 D9450C                flds    12(%ebp)
    3:func.c        ****   return a * b;
   43                    LM3:
   44 0006 D84D08                fmuls   8(%ebp)
    4:func.c        **** }
   46                    LM4:
   47 0009 5D                    popl    %ebp
   48 000a C3                    ret
   50                    Lscope0:
   52                            .text
   54 000b 90909090      Letext:
   54      90

This appears to be the sort of output you are looking for, right?

--
Tony Wetmore
Solipsys Corporation (http://www.solipsys.com)
mailto:tony.wetmore@...


Artur Krzysztof Szostak wrote:

>> I don't think there is any simple way to do this without using the -g
>> option.
>>
>> Note that the -g option does not affect code generation in any way.
>> You can use -O3 with or without -g, and you will get the same code.
>>
>
> Will the -g -O3 option truly give me code that executed at the same speed
> as -O3? I was not aware of that. In that case -g is fine. But even with -g I
> am not getting the result I want. I guess it is time for a specific example:
> Lets say I have the fillowing code in test.cxx
>
> float func(float a, float b)
> {
> return a * b;
> }
>
> and try to generate the assembly with
>
> g++ -g -O3 -Wa,-addhls test.cxx -S
>
> I would get the following (This output is truncated, I left out all the debug
> symbols at the end):
>
> # ... bla bla bla...
> .LFB2:
> .file 1 "test.cxx"
> .loc 1 3 0
> .LVL0:
> pushl %ebp
> .LCFI0:
> movl %esp, %ebp
> .LCFI1:
> .loc 1 3 0
> flds 12(%ebp)
> .LBB2:
> .loc 1 4 0
> fmuls 8(%ebp)
> .LBE2:
> .loc 1 5 0
> leave
> ret
> .LFE2:
> .size _Z4funcff, .-_Z4funcff
> # ... etc ...
>
>
> And I dont see any comments containing my c++ source lines. I would have
> expected something like:
>
> # ... bla bla bla...
> .LFB2:
> .file 1 "test.cxx"
> .loc 1 3 0
> #                     float func(float a, float b)
> #                     {
> .LVL0:
> pushl %ebp
> #                              return a * b;
> .LCFI0:
> movl %esp, %ebp
> .LCFI1:
> .loc 1 3 0
> flds 12(%ebp)
> .LBB2:
> .loc 1 4 0
> fmuls 8(%ebp)
> .LBE2:
> .loc 1 5 0
> leave
> ret
> #                       }
> .LFE2:
> .size _Z4funcff, .-_Z4funcff
> # ... etc ...
>
>
> Any ideas how to get his kind of output?
>

 « Return to Thread: Comments in assember output