[LLVMdev] [LLVM] Forward temp label references on ARM in LDR with .ltorg in inline assembly are broken in trunk

Gordon Keiser gkeiser at arxan.com
Thu Feb 20 15:45:10 PST 2014


I'm not entirely sure what caused this, but the following code, which used to behave as expected, is now broken:

---- lolwut.c ----------------------------

void lolwut(void) {
  __asm __volatile (
    "ldr r1, =1f  \n"
    ".ltorg       \n"
    "1:           \n\t"
    : : : "r0", "r1" );
}

-------------------------------------------

~/clang -target armv7-none-eabi -O0 -c -emit-llvm lolwut.c -o lolwut.bc
~/llc -O0 lolwut.bc -o lolwut.s

---- lolwut.s ----------------------------

	.file	"lolwut.bc"
	.text
	.globl	lolwut
	.align	2
	.type	lolwut,%function
lolwut:                                 @ @lolwut
	.fnstart
@ BB#0:                                 @ %entry
	@APP
	ldr	r1, .Ltmp0
	.align	2
.Ltmp0:
	.long	".L11"

".L11":

	@NO_APP
	bx	lr
.Ltmp1:
	.size	lolwut, .Ltmp1-lolwut

------------------------------------------

Somehow, the forward referenced label at 1: in the original assembly is getting mangled when its constant pool entry is created (the bad character is a 0x02 hex).   In previous versions, the inline assembly was unchanged in the output.   Does anyone know what's going on here?   I found the checkin that changed how ldr rx, = was handled but haven't had a chance to revert and try a prior revision to see if this still happens.  

I'll file a bug on this after I track down my bugzilla password but I wanted to ask here first because I'm willing to fix it if someone can point me in the right direction.  

-Gordon




More information about the llvm-dev mailing list