[LLVMdev] Re: Newbie questions

Vikram Adve
Thu, 27 Apr 2006 03:53:27 -0000

On Apr 26, 2006, at 3:23 PM, Chris Lattner wrote:

> On Wed, 26 Apr 2006, Vikram Adve wrote:
>>> On some platforms we generate explicit checks for null pointer
>>> dereferences and for division by zero (division is a bit
>>> different in
>>> that we also have to handle java's special rule for dividing -1
>>> by the
>>> minimum integer -- I think most platforms actually call the helper
>>> function).
>
>> Specifically, I don't think either of these approaches will be
>> sufficient when using LLVM as a JIT in libgcj.  In either case, an
>> LLVM optimization could still reorder trapping instructions.  In
>> the first approach, this is less likely to occur but is possible.
>> The second approach of course wouldn't work because LLVM
doesn't
>> have a notion of implicitly trapping instructions and could
>> merrily reorder such operations.
>
> Vikram, I'm confused.  How do you think LLVM will break this?

By reordering two instructions that could throw exceptions.


> It will never introduce a trapping operation on a path without a trap,

That isn't required to break it as above.


> and the approach above doesn't require the ability to distinguish
> between traps: in fact, any trap would be a fatal error.

I'm talking about non-fatal conditions like divide-by-0 or a null
reference that are caught by exception handlers.