From 12569fb55db2a8181711ac134b7479155db4f838 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 10 Jul 2011 03:38:35 +0000 Subject: [PATCH] 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 --- lib/CodeGen/CGExpr.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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(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(Value->getType())) { + llvm::Type *EltTy = + cast(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); -- 2.11.4.GIT