[llvm-dev] Question on Aliasing and invariant load hoisting

Venkataramanan Kumar via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 8 23:10:30 PDT 2019


Hi Tim,

Thank you for the clarifying this.

On Tue, 9 Jul 2019 at 00:58, Tim Northover <t.p.northover at gmail.com> wrote:

> Hi Venkataramanan,
>
> On Mon, 8 Jul 2019 at 19:31, Venkataramanan Kumar via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> > is it because the "obj.a" can alias with "ptr" ?
>
> Yes. At the IR level there's nothing to stop @bar from
> getelementptring backwards and accessing other parts of %1.
>
> I believe it would be somewhere between invalid and
> implementation-defined[*] at the C or C++ levels, but modelling that
> would be quite tricky. I thnk you'd need some kind of finer-grained
> escape analysis, supported by metadata (because there are constructs
> with otherwise very similar IR that *are* valid, for example if obj
> was an int[2]).
>
> Cheers.
>
> Tim.
>
>
So we can still do some inter procedural analysis, and check if only the
passed bytes is accessed in all those escaping places?



> [*] Casts to/from ints are implementation-defined, so a compiler could
> allow it via "(int *)((uintptr_t)x - 4)" regardless of what the
> standard otherwise says. I don't recall seeing any discussion on
> whether Clang does or wants to do that.
>

regards,
Venkat.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190709/1565026b/attachment-0001.html>


More information about the llvm-dev mailing list