iphone + LDC, a new ARM adventure

David Nadlinger code at klickverbot.at
Thu Jan 9 01:28:20 PST 2014


Hi Dan,

On 8 Jan 2014, at 18:39, Dan Olson wrote:
> By the way, llc is very cool.  As I said, I am totally new to llvm
> internals, so am having fun learning what it has in its magic bag of
> tricks.

Glad to hear you are having fun. ;) By the way, are you aware of the 
dump() functions that LLVM offers on many of its objects (llvm::Type, 
llvm::Value, …)? They are very useful when debugging inside gdb, as 
they let you print out the contents of an object in a human-readable 
form (usually LLVM IR). For example, to track down what exactly causes 
the assertion failure you were seeing, you could simply run LDC (linked 
against a debug build of LLVM) in GDB, go up a few levels in the call 
stack, and then dump the various parameters to see where exactly the 
bitcast goes wrong. You can even dump entire LLVM functions/modules 
(e.g. try "p gIR->module->dump()" when debugging LDC), which is 
sometimes useful to orient oneself when debugging a complex code 
generation problem.

> So far I cannot find where clang adds the bitcast thing for sjlj eh
> personality.  I will keep hunting.  Any ideas where I would do this in
> ldc?

As Kai mentioned, this is/should really be fixed in LLVM, but in case 
you are curious: The landing pad instructions are created in 
createLandingPadInst() (ir/irlandingpad.cpp), I'd just insert a bitcast 
(e.g. using the DtoBitCast helper) there. You can use 
gTargetMachine->getMCAsmInfo()->getExceptionHandlingType() to determine 
which EH style LLVM will lower the instructions too.

Generally, I'd really recommend working with the latest LLVM version 
when tackling a new port, though. Especially for some of the non-x86 
targets, there is usually quite a bit of progress behind the releases, 
and if you need to patch LLVM at some point, it will take less effort to 
upstream your changes.

> When it comes to updating the _d_eh_personality for sjlj, I noticed a
> very small difference in the c++ versions ( _gxx_personality_v0 and
> _gxx_personality_sj0).  It is actually one funtion body in
>
> gcc-4.8-20121028/libstdc++-v3/libsupc++/eh_personality.cc
>
> with a little extra code in an ifdef _GLIBCXX_SJLJ_EXCEPTIONS
> conditional.

Yep, I also noticed that when working on ARM EABI EH support a few days 
back. Let's hope for the best – although the ARM EABI unwinder changes 
were only a few lines too, but took quite a bit of effort to 
reverse-engineer.

Best,
David


More information about the digitalmars-d-ldc mailing list