[LLVMdev] Newbie questions

Archie Cobbs archie at dellroad.org
Mon Apr 24 10:29:18 PDT 2006


Vikram Adve wrote:
> If you're only interested in using LLVM for "cool things" (such as  
> optimization), you could use it directly on the C code you emit.

Yes... though the translation to C loses some efficiency due to
"impedance mismatch". More ideal would be to go from bytecode -> LLVM
directly (I understand this part has already been done more or less).

> Either way, one issue that you will have to deal with is preserving  the 
> behavior of Java exceptions (assuming you care about that).  LLVM  does 
> not preserve the order of potentially excepting instructions  (e.g., a 
> divide or a load).  This would have to be handled  explicitly, whether 
> you use llvm-java or simply used LLVM on the C  code from Soot.  I don't 
> know if/how libgcj handles this but Tom may  be able to say more about 
> that.

Right.. I think we'd have to revert to signal-less exception checking
for null pointer and divide-by-zero for the time being.

But this brings up a good point.. should LLVM have an "instruction
barrier" instruction? I.e., an instruction which, within the context
of one basic block, would prevent any instructions before the barrier
from being reordered after any instructions after the barrier?

Then a JVM could use signals and still guarantee Java's "exactness"
of exceptions by bracketing each potentially-signal-generating instruction
with instruction barriers.

Someone must have already invented this and given it a better name.

Related idea.. what if all instructions (not just "invoke") could be
allowed to have an optional "except label ..."?

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com




More information about the llvm-dev mailing list