[PATCH] Address Space Casting

Eli Friedman eli.friedman at gmail.com
Wed Sep 4 12:59:44 PDT 2013


On Wed, Sep 4, 2013 at 4:56 AM, David Chisnall
<David.Chisnall at cl.cam.ac.uk>wrote:

> On 4 Sep 2013, at 00:01, Eli Friedman <eli.friedman at gmail.com> wrote:
>
> > On Tue, Sep 3, 2013 at 3:01 PM, Michele Scandale <
> michele.scandale at gmail.com> wrote:
> >
> >
> > ================
> > Comment at: lib/IR/AutoUpgrade.cpp:404
> > @@ +403,2 @@
> > +  return Opc;
> > +}
> > ----------------
> > Eli Friedman wrote:
> > > This isn't appropriate: this transformation changes the semantics of
> the code.  bitcast is explicitly not equivalent to addrspacecast; it's
> equivalent to a ptrtoint+inttoptr pair.
> > From what have been discussed before (
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-August/064674.html) seems
> that before bitcast was used to convert two pointers between different
> address spaces... That's the reason for that code....
> >
> > "bitcast" has always been defined in LangRef as a no-op.  The whole
> reason for adding addrspacecast is precisely because it isn't a no-op.
>  They are clearly not equivalent.
>
> Bitcasts between address spaces are now undefined, so there are two
> choices for the upgrader:
>
> - Turn them into addrspacecasts
> - Leave the module invalid, in such a state that it will not pass the
> verifier
>
> It makes more sense to me to have the first behaviour, because the only
> case where the original bitcast would make sense is the case where the
> bitcast was used because there was no addrspacecast instruction.
>

Or it could have been a ptrtoint+inttoptr pair originally, which would get
turned into a bitcast by instcombine.

I don't see what's wrong with the choice of turning such a bitcast back
into a ptrtoint+inttoptr pair.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130904/4d848ad2/attachment.html>


More information about the llvm-commits mailing list