iphone + LDC, a new ARM adventure

Kai Nacke kai at redstar.de
Sun Jan 19 22:56:29 PST 2014


Hi Dan!

On Sunday, 19 January 2014 at 00:48:47 UTC, Dan Olson wrote:
> Well, I am kind of stuck and am going to have to start learning 
> LLVM
> internals to go further.
>
> I can build entire druntime and phobos for iOS if I target 
> thumb 16-bit
> with llvm-3.4.  However, every function that must handle 
> exceptions ends
> up with a bad prologue/epilogue.  I get the same problem with 
> clang++,
> so it is not an ldc issue.  I am pretty sure it is related to 
> sjlj eh.
>
> For example, a c++ function that has a try/catch 
> (-mtriple=thumbv6-darwin):
>
> 	.thumb_func	__Z3barv
> __Z3barv:
> 	.cfi_startproc
> 	.cfi_personality 155, L___gxx_personality_sj0$non_lazy_ptr
> Leh_func_begin0:
> 	.cfi_lsda 16, Lexception0
> @ BB#0:                                 @ %entry
> 	push	{d8, d9, d10, d11, d12, d13, d14, d15, r8, r10, r11, r4, 
> r5, r6, r7, lr}
> 	add	r7, sp, #12
>         ...
> 	pop	{d8, d9, d10, d11, d12, d13, d14, d15, r8, r10, r11, r4, 
> r5, r6, r7, pc}
>
> The pop and push are incorrect and using otool to disassemble 
> shows what
> really ends up in the .o, which is a proper instruction, but 
> will not work.
>
> __Z3barv:
> 00000000	    b420	push	{r5}
> 00000002	    af03	add	r7, sp, #12
> ...
> 00000050	    bc20	pop	{r5}
>
> I think it should be more like:
> 	push	{r4, r5, r6, r7, lr}
> 	pop  	{r4, r5, r6, r7, pc}
>
> Perhaps I need to go back to working on targeting armv7 or 
> thumb2.  Its
> assembly looks better for exception handling, but I get 
> assertion failures from
> llvm-3.4 on several files in druntime.  Maybe llvm trunk will 
> be better?
>
> Dan

I think using trunk is always the best option if you port ldc to 
a new platform. I try to keep ldc in sync with LLVM trunk 
therefore you should have no problems with using trunk.

If the bug is also present in trunk then you should enter a bug 
report at http://llvm.org/bugs. It sounds pretty bad.

Could you please post which triple you are suing and on which 
druntime files you get assertion errors? An assertion in LLVM may 
also be triggered by bad IR. I like to have a look at it.

Regards,
Kai


More information about the digitalmars-d-ldc mailing list