[LLVMdev] RFC: change BoundsChecking.cpp to use address-based tests
Nuno Lopes
nunoplopes at sapo.pt
Tue Dec 4 14:30:52 PST 2012
Hi,
> Could you provide a bit of background of the expected domains of Size and
> Offset? In particular, are they signed or unsigned integers? A
> non-negative size doesn't seem to make much sense in this context, but
> depending on how it's calculated I could see it arising. Is a zero Size
> something that might arise here? I'm assuming the Offset comes from an
> arbitrary indexing expression and is thus a signed integer.
Ok, so we have the following:
- Size is unsigned
- Offset is signed (in LLVM, like in C, offsets can be negative)
- Offset can be < 0, but that's an error, since the offset is computed from
the beginning of the object
- Size can be zero
> By working through the cases, I've identified combinations of two
> conditionals which should work if either a) Size is positive, or b) Size
> and Offset are both signed integers. Once I know which, if either, is
> appropriate, I'll write it up with a full explanation of why I think it
> works. Then we can discuss. If I'm right about the changed conditionals
> working, I'd then write up a patch for submission.
We already optimize the case when Size is >= 0 (signed comparison). In this
case we only do 2 comparisons.
The other case that is optimized is when Offset is a constant. We only do 2
comparisons in that case as well.
Please send in your suggestions :)
Thanks,
Nuno
More information about the llvm-dev
mailing list