iphone + LDC, a new ARM adventure

Dan Olson zans.is.for.cans at yahoo.com
Sat Jan 18 16:48:47 PST 2014


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




More information about the digitalmars-d-ldc mailing list