Am 05.12.2012 06:19, schrieb Sergio Durigan Junior:
Don't want to cause any flamewars here (nor to hijack the thread),
me neither
but can you provide an example?
You can use the various -d* (I'm thinking
about -dp here, actually) options on GCC to make it annotate the
assembler.
-dp provides a very low level annotation of every assembler statement,
usually not what *I* need to understand the assembler something like
uComp:
..LFB683:
.cfi_startproc
testq %rdx, %rdx # 10 *cmpdi_ccno_1/1 [length = 3]
je .L586 # 11 *jcc_1 [length = 2]
movq (%rdx), %rcx # 13 *movdi_internal_rex64/2 [length = 3]
xorl %edx, %edx # 88 *movdi_xor [length = 2]
movq (%rdi), %rax # 14 *movdi_internal_rex64/2 [length = 3]
divq %rcx # 76 *udivmoddi4_noext [length = 3]
movq (%rsi), %rax # 17 *movdi_internal_rex64/2 [length = 3]
movq %rdx, %rdi # 71 *movdi_internal_rex64/2 [length = 3]
xorl %edx, %edx # 89 *movdi_xor [length = 2]
divq %rcx # 78 *udivmoddi4_noext [length = 3]
xorl %ecx, %ecx # 90 *movsi_xor [length = 2]
cmpq %rdx, %rdi # 91 *cmpdi_1/1 [length = 3]
movl $-1, %eax # 7 *movsi_internal/1 [length = 5]
seta %cl # 92 *setcc_qi_slp [length = 3]
cmovae %ecx, %eax # 63 *movsicc_noc/1 [length = 3]
ret # 82 return_internal [length = 1]
.p2align 4,,10
.p2align 3
..L586:
movq (%rsi), %rcx # 72 *movdi_internal_rex64/2 [length = 3]
xorl %edx, %edx # 85 *movsi_xor [length = 2]
movl $-1, %eax # 6 *movsi_internal/1 [length = 5]
cmpq %rcx, (%rdi) # 86 *cmpdi_1/1 [length = 3]
seta %dl # 87 *setcc_qi_slp [length = 3]
cmovae %edx, %eax # 67 *movsicc_noc/1 [length = 3]
ret # 84 return_internal [length = 1]
.cfi_endproc
..LFE683:
.size uComp, .-uComp
Don't know how clang annotates it, I don't have it installed
here.
Clang (with just -S) annotates the same code more lightly but with
higher level annotations corresponding to the structure of the source,
here in particular the if-then-else constructs that generated the
branching.
uComp: # @uComp
.cfi_startproc
# BB#0: # %entry
testq %rdx, %rdx
je .LBB9_3
# BB#1: # %if.then
movq (%rsi), %rax
movq (%rdx), %rsi
xorl %edx, %edx
divq %rsi
movq %rdx, %rcx
movq (%rdi), %rax
xorl %edx, %edx
divq %rsi
movl $-1, %eax
cmpq %rcx, %rdx
jb .LBB9_5
# BB#2: # %cond.false
cmpq %rcx, %rdx
jmp .LBB9_4
..LBB9_3: # %if.else
movq (%rsi), %rcx
movq (%rdi), %rdx
movl $-1, %eax
cmpq %rcx, %rdx
jb .LBB9_5
..LBB9_4: # %cond.false.i
seta %al
movzbl %al, %eax
..LBB9_5: # %return
ret
..Ltmp115:
.size uComp, .Ltmp115-uComp
.cfi_endproc
Jens