[LLVMdev] [compiler-rt] CMake bug in building ARM builtins library

Jonathan Roelofs
Thu, 17 Jul 2014 22:17:01 -0000

Oh yeah, Tim and I discussed this exact issue on irc the other day...

I should have filed a PR. Oops.


Jon

On 7/17/14, 1:11 PM, sgundapa wrote:
> +Tim Northover
>
> I added ".syntax unified" to the sync_fetch_* .S files and the
> "-no-integrated-as" path moved ahead and failed with
> Error: branch out of range
>
> No Integrated asm path:
>
> .p2align 2 ;
>   .thumb ;
>   .syntax unified ;
>   ;
>   .globl __sync_fetch_and_add_8 ;
>   .type __sync_fetch_and_add_8,%function ;
>   __sync_fetch_and_add_8: push {r4, r5, r6, lr} ;
>   dmb ;
>   mov r12, r0 ;
>   .L_tryatomic_add_8: ldrexd r0, r1, [r12] ;
>   adds r4, r0, r2 ;
>   adc r5, r1, r3 ;
>   strexd r6, r4, r5, [r12] ;
>   cbnz r6, .L_tryatomic_add_8 ;
>   dmb ;
>   pop {r4, r5, r6, pc}
>
> The ARM manual on CBNZ says backward branching is not possible.
> Refer to
>
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cjaghef
> c.html
>
>
>
> Integrated asm path:
> Surprisingly, integrated-as compiles the file and the objdump looks invalid
>
> Disassembly of section .text:
> 00000000 <__sync_fetch_and_add_8>:
>     0:	b570      	push	{r4, r5, r6, lr}
>     2:	f3bf 8f5f 	dmb	sy
>     6:	4684      	mov	ip, r0
>     8:	e8dc 017f 	ldrexd	r0, r1, [ip]
>     c:	1884      	adds	r4, r0, r2
>     e:	eb41 0503 	adc.w	r5, r1, r3
>    12:	e8cc 4576 	strexd	r6, r4, r5, [ip]
>    16:	bbbe      	cbnz	r6, 88 <__sync_fetch_and_add_8+0x88>
>    18:	f3bf 8f5f 	dmb	sy
>    1c:	bd70      	pop	{r4, r5, r6, pc}
>
> There is no <__sync_fetch_and_add_8+0x88> at least as I could tell
>
> There are two issues here:
> 1. We need to update the sync_fetch_* files to generate proper assembly
> 2. How clang ARM MC is accepting the above assembly to compile.
>
> --Sumanth G
>
> -----Original Message-----
> From: Jonathan Roelofs [mailto:jonathan at codesourcery.com]
> Sent: Wednesday, July 16, 2014 7:37 PM
> To: sgundapa; 'Alexey Samsonov'
> Cc: 'LLVM Dev'
> Subject: Re: [LLVMdev] [compiler-rt] CMake bug in building ARM builtins
> library
>
>
>
> On 7/16/14, 6:09 PM, sgundapa wrote:
>> I see a couple of issues here.
>>
>> If I include .S files for ARM, the -no-integrated-as path complains
>> about Assembler errors.
>>
>> The integrated-as path works fine though.
>>
>
> These are very likely just differences between the old ARM assembler syntax
> and the new 'Unified' syntax.  Can you use an assembler that
accepts UAL
> syntax?
>
> Regards,
> Jon
>
>
> --
> Jon Roelofs
> jonathan at codesourcery.com
> CodeSourcery / Mentor Embedded