assembly output

Hi,

Is there a way to tell clang to generate a more human-readable
assembly? And probably without any optimizations?

The way I'm doing is (I'm on Linux/Ubuntu x86_64 if that matters):

$ clang++ -S -c empty.cc

Files attached.

empty.cc (27 Bytes)

empty.s (458 Bytes)

From clang’s -help:

-masm-verbose Generate verbose assembly output

– Sean Silva

Clang supports different optimization levels, by default it is O0. O0 which is same as not specifying an optimization level does not do any optimization as such.

A more detailed document is very much needed to understand the levels better. Here is a thread discussing the same.
http://clang-developers.42468.n3.nabble.com/Meaning-of-LLVM-optimization-levels-td4032493.html

Thanks,
Rahul

Copying clang-dev again, :frowning:

What’s unreadable about empty.s that’s better with objdump? It seems fine. Is it the .cfi directives?

Yeah, I think it's that.

Compare this (objdump --dissamble disa):

0000000000400510 <_Z3sumv>:
  400510: 55 push %rbp
  400511: 48 89 e5 mov %rsp,%rbp
  400514: b8 03 00 00 00 mov $0x3,%eax
  400519: 5d pop %rbp
  40051a: c3 retq
  40051b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)

To (clang++ -S disa.cc):

_Z3sumv: # @_Z3sumv
             .cfi_startproc
# BB#0: # %entry
            pushq %rbp

disa.cc (75 Bytes)

disa.s (956 Bytes)

What's unreadable about empty.s that's better with objdump? It seems fine.
Is it the .cfi directives?

Yeah, I think it's that.

Compare this (objdump --dissamble disa):

--disassemble