iphone + LDC, a new ARM adventure

Dan Olson zans.is.for.cans at yahoo.com
Thu Jan 9 21:24:47 PST 2014


"David Nadlinger" <code at klickverbot.at> writes:

> 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.

Sounds cool.  I have not tried any of that yet.

>
>> 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.

Getting 3.4 now and will see what happens.

>> 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.

Yeah, low level code code can take sometime to get right.  But it can be
a master piece that you proudly look at and say, "it all fit in 256
bytes".  Embedded assembly is my favorite.  Now I need to get familiar
with ARM assembly.


More information about the digitalmars-d-ldc mailing list