Reputation: 765
I am trying to mark my ASM (generate by the compiler) to make a postpone analysis between my mark my analysis the corresponding .s file. The following MACRO works with GCC
#define ASM_LABEL(label) asm ("#" label "\n\t")
Nevertheless with CLANG the label is removed.
void kernel(double const * x, double * y){
ASM_LABEL (START)
y[0]+=x[1]+x[3]/x[4];
y[1] = std::exp(x[0]);
ASM_LABEL (STOP)
}
The generated ASM (clang -O3 -S) gives:
movq %rdi, -8(%rbp)
movq %rsi, -16(%rbp)
## InlineAsm Start
## InlineAsm End <---- no START mark
movq -8(%rbp), %rsi
movsd 8(%rsi), %xmm0
movq -8(%rbp), %rsi
..............
The label has been deleted. Do you have any suggestion ? Does exist an generic tips ?
Thank you
Upvotes: 1
Views: 528
Reputation: 1584
clang will, by default, use its integrated llvm assembler, but this can be disabled with the command line option -fno-integrated-as
.
Specifying this along with -S
should preserve the comments from the inline asm. Running clang -S -O3 -fno-integrated-as
on the code sample
#include <cmath>
#define ASM_LABEL(label) asm ("#" label "\n\t" ::: "memory");
void kernel(double const * x, double * y){
ASM_LABEL("START")
y[0]+=x[1]+x[3]/x[4];
y[1] = std::exp(x[0]);
ASM_LABEL("STOP")
}
Gives the assembly (leaving out directives and labels):
pushq %rbx
movq %rsi, %rbx
#APP
#START
#NO_APP
movsd 24(%rdi), %xmm0
divsd 32(%rdi), %xmm0
addsd 8(%rdi), %xmm0
addsd (%rbx), %xmm0
movsd %xmm0, (%rbx)
movsd (%rdi), %xmm0
callq exp
movsd %xmm0, 8(%rbx)
#APP
#STOP
#NO_APP
popq %rbx
retq
Upvotes: 1