[PATCH] Fix assert with copy from global through addrspacecast
Michele Scandale
michele.scandale at gmail.com
Fri Dec 6 16:06:09 PST 2013
The suggested name won't be ambiguous, so +1.
BTW, I don't see the problem, if a non pointer value is passed, an addrspacecast would be illegal because it requires a pointer value, while a bitcast would be valid w.r.t. its constraints.
Constant *ConstantExpr::getBitCastOrAddrSpaceCast(Constant *S, Type *Ty) {
assert((CastInst::castIsValid(Instruction::BitCast, S, Ty) ||
CastInst::castIsValid(Instruction::AddrSpaceCast, S, Ty)) &&
"Invalid cast");
unsigned SrcTy = S->getType();
if (Ty->isPtrOrPtrVectorTy() && DestTy->isPtrOrPtrVectorTy() &&
SrcTy->getPointerAddressSpace() != Ty->getPointerAddressSpace())
return getAddrSpaceCast(S, Ty);
return getBitCast(S, Ty);
}
But maybe something like this could just an helper in IRBuilder...
http://llvm-reviews.chandlerc.com/D2205
More information about the llvm-commits
mailing list