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
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.
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):
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
# BB#0: # %entry
disa.cc (75 Bytes)
disa.s (956 Bytes)