when emitting pointer load from an lvalue or storing to an lvalue,

do an explicit bitcast to whatever ConvertType produces.  This will
go with the next patch.

llvm-svn: 134860
This commit is contained in:
Chris Lattner
2011-07-10 03:38:35 +00:00
parent 3310effb24
commit 1a5f8978e9

View File

@@ -756,6 +756,10 @@ llvm::Value *CodeGenFunction::EmitFromMemory(llvm::Value *Value, QualType Ty) {
return Builder.CreateTrunc(Value, Builder.getInt1Ty(), "tobool");
}
// If this is a pointer r-value, make sure that it has the right scalar type.
if (isa<llvm::PointerType>(Value->getType()))
return Builder.CreateBitCast(Value, ConvertType(Ty));
return Value;
}
@@ -764,6 +768,14 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr,
QualType Ty,
llvm::MDNode *TBAAInfo) {
Value = EmitToMemory(Value, Ty);
if (isa<llvm::PointerType>(Value->getType())) {
llvm::Type *EltTy =
cast<llvm::PointerType>(Addr->getType())->getElementType();
if (EltTy != Value->getType())
Value = Builder.CreateBitCast(Value, EltTy);
}
llvm::StoreInst *Store = Builder.CreateStore(Value, Addr, Volatile);
if (Alignment)
Store->setAlignment(Alignment);