[PATCH] Fix assert with copy from global through addrspacecast

Michele Scandale michele.scandale at gmail.com
Fri Dec 6 15:35:26 PST 2013



================
Comment at: lib/IR/Constants.cpp:1510
@@ +1509,3 @@
+  return getBitCast(S, Ty);
+}
+
----------------
Matt Arsenault wrote:
> Michele Scandale wrote:
> > Matt Arsenault wrote:
> > > Michele Scandale wrote:
> > > > Maybe this function can be fused within getPointerCast in order to support there the case of pointers with different address spaces.
> > > I tried that originally, but the results weren't satisfying. The asserts are different since getBitCastOrAddrSpaceCast only accepts pointer<->pointer casts, while getPointerCast accepts integer destinations.
> > That's ok, IMHO a more general name would be better (like getPointerToPointerCast).
> > 
> > However, the getPointerCast must be fixed in order to create the proper cast also when the destination type has a different address space with respect to the source Constant.
> That is already handled, I just updated the comment
I think that the semantic for 'getBitCastOrAddrSpaceCast' should be to pick a bitcast wheter is valid or an addrspace cast whether is valid or assert.
A set of functions like this, also for instructions, and a wrapper in the IRBuilder will be very useful to simplify the upgrade of the frontend and other tools to the new bitcast semantic and the new instruction (e.g. where previously there was a CreateBitCast now a CreateBitCastOrAddrSpaceCast would be fine).

What do you think about this?


http://llvm-reviews.chandlerc.com/D2205



More information about the llvm-commits mailing list