[cfe-commits] r95430 - in /cfe/trunk/lib/CodeGen: CGDecl.cpp CGExpr.cpp CGStmt.cpp

Douglas Gregor dgregor at apple.com
Fri Feb 5 13:10:36 PST 2010


Author: dgregor
Date: Fri Feb  5 15:10:36 2010
New Revision: 95430

URL: http://llvm.org/viewvc/llvm-project?rev=95430&view=rev
Log:
Revert r95393, which broke Clang's self-host.

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

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=95430&r1=95429&r2=95430&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Feb  5 15:10:36 2010
@@ -690,19 +690,25 @@
   CanQualType CTy = getContext().getCanonicalType(Ty);
 
   llvm::Value *DeclPtr;
-  // If this is an aggregate or variable sized value, reuse the input pointer.
-  if (!Ty->isConstantSizeType() ||
-      CodeGenFunction::hasAggregateLLVMType(Ty)) {
+  if (!Ty->isConstantSizeType()) {
+    // Variable sized values always are passed by-reference.
     DeclPtr = Arg;
   } else {
-    // Otherwise, create a temporary to hold the value.
-    DeclPtr = CreateTempAlloca(ConvertTypeForMem(Ty));
-    DeclPtr->setName(D.getName() + ".addr");
+    // A fixed sized single-value variable becomes an alloca in the entry block.
+    const llvm::Type *LTy = ConvertTypeForMem(Ty);
+    if (LTy->isSingleValueType()) {
+      // TODO: Alignment
+      DeclPtr = CreateTempAlloca(LTy);
+      DeclPtr->setName(D.getNameAsString() + llvm::StringRef(".addr"));
 
-    // Store the initial value into the alloca.
-    EmitStoreOfScalar(Arg, DeclPtr, CTy.isVolatileQualified(), Ty);
+      // Store the initial value into the alloca.
+      EmitStoreOfScalar(Arg, DeclPtr, CTy.isVolatileQualified(), Ty);
+    } else {
+      // Otherwise, if this is an aggregate, just use the input pointer.
+      DeclPtr = Arg;
+    }
+    Arg->setName(D.getNameAsString());
   }
-  Arg->setName(D.getName());
 
   llvm::Value *&DMEntry = LocalDeclMap[&D];
   assert(DMEntry == 0 && "Decl already exists in localdeclmap!");

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=95430&r1=95429&r2=95430&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Feb  5 15:10:36 2010
@@ -549,13 +549,14 @@
 
   if (LV.isSimple()) {
     llvm::Value *Ptr = LV.getAddress();
+    const llvm::Type *EltTy =
+      cast<llvm::PointerType>(Ptr->getType())->getElementType();
 
     // Simple scalar l-value.
-    if (!CodeGenFunction::hasAggregateLLVMType(ExprType))
+    if (EltTy->isSingleValueType())
       return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(),
                                           ExprType));
 
-    // FIXME: This case shouldn't be necessary?
     assert(ExprType->isFunctionType() && "Unknown scalar value");
     return RValue::get(Ptr);
   }

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=95430&r1=95429&r2=95430&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Feb  5 15:10:36 2010
@@ -861,13 +861,14 @@
                                            std::string &ConstraintStr) {
   llvm::Value *Arg;
   if (Info.allowsRegister() || !Info.allowsMemory()) {
-    if (!CodeGenFunction::hasAggregateLLVMType(InputExpr->getType())) {
+    const llvm::Type *Ty = ConvertType(InputExpr->getType());
+
+    if (Ty->isSingleValueType()) {
       Arg = EmitScalarExpr(InputExpr);
     } else {
       InputExpr = InputExpr->IgnoreParenNoopCasts(getContext());
       LValue Dest = EmitLValue(InputExpr);
 
-      const llvm::Type *Ty = ConvertType(InputExpr->getType());
       uint64_t Size = CGM.getTargetData().getTypeSizeInBits(Ty);
       if (Size <= 64 && llvm::isPowerOf2_64(Size)) {
         Ty = llvm::IntegerType::get(VMContext, Size);





More information about the cfe-commits mailing list