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 | 1a5f8978e98759d47a69d03de67d9c516ce11f82 (patch) | |
tree | 8810c2f184a13d0bbc7824e3f60ff74386818b12 /clang/lib/CodeGen/CGExpr.cpp | |
parent | 3310effb24d90feae761b61271d1c8d7ad47cca0 (diff) | |
download | bcm5719-llvm-1a5f8978e98759d47a69d03de67d9c516ce11f82.tar.gz bcm5719-llvm-1a5f8978e98759d47a69d03de67d9c516ce11f82.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 5d721629383..c7a104ea451 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/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); |