Skip to content

[inline-asm] clang doesn't accept the operand %1 #97673

@vfdff

Description

@vfdff
void _mcount(uint64_t caller_ra){
	uint64_t rbp=0;
	uint64_t rsp=0;
	__asm__ __volatile__("mov x0, fp\n"
                         "mov %1, sp \n"
                         :"=g"(rbp),"=g"(rsp)       
                         :); 
	
	printf("rbp = 0x%llx , rsp=0x%llx\n" , rbp , rsp);
}

I except the register value sp will be saved in local variable rsp. But it is only accept by gcc

gcc -c -o testhello.o testhello.c -pg -g

  • error reported by clang:
<source>:9:27: error: invalid operand for instruction
    9 |                          "mov %1, sp \n"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions