Android/ARM codegen

Joakim via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Thu Jul 16 10:07:32 PDT 2015


On Thursday, 16 July 2015 at 16:40:31 UTC, Dan Olson wrote:
> "Joakim" <dlang at joakim.fea.st> writes:
>>
>> The problem appears to be that even though r4 is saved at the 
>> beginning of the function, it is overwritten by r1 in the 
>> stmib instruction afterwards.  Obviously there's no point in 
>> pushing r4 and popping it at the end of the function, if 
>> you've lost it by overwriting in between.  Specifically, "sub 
>> sp, sp, #8" advances the stack pointer by 8, then stmib 
>> increments it 4 _before_ storing r0 then r1, overwriting the 
>> contents of r4 saved at the beginning of the function.  Other 
>> calls to map also seem to fail in other instances of the same 
>> template function, but interestingly in different ways, ie no 
>> uses of stmib there.  I haven't tracked down exactly why those 
>> other instances fail.
>
> That doesn't look right.
>
> What is your triple and other options (optimization), llvm 
> version your patched src is based on, and ldc branch 
> (merge-2.067 branch I think)? I'd like to compare the asm 
> snippet with what I get get for thumbv7-apple-ios, because it 
> should be similar, but it passes std.zip.
>
> It could be I just haven't stumbled into the combination you 
> are using.

llvm triple and other flags used:

--output-o -w -d -mtriple=armv7-none-linux-androideabi 
-relocation-model=pic -O3 -release -unittest

ldc was compiled against a locally-compiled llvm 3.6 from the 
Android NDK repo, which has some modifications:

https://android.googlesource.com/toolchain/llvm/+log/release_36

Yes, I'm using the merge-2.067 branch of ldc as of commit 
122ea372d from a couple weeks ago, with inlining turned off, as 
noted in the earlier EH thread.  I would be curious to see what 
llvm IR and ARM assembly is generated for you on iOS and what 
other flags you're using.  The actual function shown is from the 
std.random module.


More information about the digitalmars-d-ldc mailing list