aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-10 03:38:35 +0000
committerChris Lattner <sabre@nondot.org>2011-07-10 03:38:35 +0000
commit12569fb55db2a8181711ac134b7479155db4f838 (patch)
treedb1a54df66eb8b11645119eabbb3d184fb070132 /lib/CodeGen/CGExpr.cpp
parent0989bf7b7a5abaf5a7764c32921d7eafa316ba58 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134860 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r--lib/CodeGen/CGExpr.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 5d72162938..c7a104ea45 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -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);