diff options
author | Chris Lattner <sabre@nondot.org> | 2011-07-10 03:38:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-07-10 03:38:35 +0000 |
commit | 12569fb55db2a8181711ac134b7479155db4f838 (patch) | |
tree | db1a54df66eb8b11645119eabbb3d184fb070132 /lib/CodeGen/CGExpr.cpp | |
parent | 0989bf7b7a5abaf5a7764c32921d7eafa316ba58 (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.cpp | 12 |
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); |