[PATCH] Address Space Casting

David Chisnall David.Chisnall at cl.cam.ac.uk
Wed Sep 4 04:56:39 PDT 2013


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.

David





More information about the llvm-commits mailing list