[LLVMdev] Canonicalization of ptrtoint/inttoptr and getelementptr
Reid Kleckner
rnk at google.com
Mon Sep 8 20:36:07 PDT 2014
On Mon, Sep 8, 2014 at 4:22 PM, Dan Gohman <dan433584 at gmail.com> wrote:
> It looks a little silly to say this in the case of the integer constant 5,
> and there are some semantic gray areas around extra-VM allocation, but the
> same thing happens if the add were adding a dynamic integer value, and then
> it's difficult to find a way to separate that case from the constant 5 case.
>
Could we say that constant integers have no objects associated with them?
If so, we need a way to bless constant integers that *do* refer to real
objects, such as ASan's shadow memory base.
Then you should be able to take something like add a phi of constant ints
to an inttoptr and transform that to a GEP, without explicitly calling out
constant integers.
> In any case, the general advice is that people should prefer to use
> getelementptr to begin with. LLVM's own optimizers were converted to use
> getelementptr instead of ptrtoint+add+inttoptr even when they have to do
> raw byte arithmetic.
>
I'm guessing the IR comes from C++ code that subtracts pointers, so it'd be
good if we could figure this out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140908/e2c6d3e5/attachment.html>
More information about the llvm-dev
mailing list