[cfe-commits] r134860 - /cfe/trunk/lib/CodeGen/CGExpr.cpp

Chris Lattner sabre at nondot.org
Sat Jul 9 20:38:35 PDT 2011


Author: lattner
Date: Sat Jul  9 22:38:35 2011
New Revision: 134860

URL: http://llvm.org/viewvc/llvm-project?rev=134860&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=134860&r1=134859&r2=134860&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat Jul  9 22:38:35 2011
@@ -756,6 +756,10 @@
     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 @@
                                         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);





More information about the cfe-commits mailing list