[cfe-commits] r111794 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenCXX/x86_64-arguments.cpp

Chris Lattner sabre at nondot.org
Sun Aug 22 22:26:13 PDT 2010


Author: lattner
Date: Mon Aug 23 00:26:13 2010
New Revision: 111794

URL: http://llvm.org/viewvc/llvm-project?rev=111794&view=rev
Log:
fix rdar://8340348, a miscompile of boost that was exposed by r109848.
That revision started classifying truly empty structs like "Y" and "X"
as being NoClass/NoClass and turning them into 'ignore'.  The call code
turns around and allocates space for the ignored argument with 
GetUndefRValue.  The bug is that GetUndefRValue would return the address
as undef, instead of returning an object with a defined address but 
undefined contents.

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=111794&r1=111793&r2=111794&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Aug 23 00:26:13 2010
@@ -441,9 +441,12 @@
     return RValue::getComplex(std::make_pair(U, U));
   }
   
+  // If this is a use of an undefined aggregate type, the aggregate must have an
+  // identifiable address.  Just because the contents of the value are undefined
+  // doesn't mean that the address can't be taken and compared.
   if (hasAggregateLLVMType(Ty)) {
-    const llvm::Type *LTy = llvm::PointerType::getUnqual(ConvertType(Ty));
-    return RValue::getAggregate(llvm::UndefValue::get(LTy));
+    llvm::Value *DestPtr = CreateMemTemp(Ty, "undef.agg.tmp");
+    return RValue::getAggregate(DestPtr);
   }
   
   return RValue::get(llvm::UndefValue::get(ConvertType(Ty)));

Modified: cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp?rev=111794&r1=111793&r2=111794&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp Mon Aug 23 00:26:13 2010
@@ -76,3 +76,27 @@
     return b2.b1.pa;
   }
 }
+
+namespace test5 {
+  struct Xbase { };
+  struct Empty { };
+  struct Y;
+  struct X : public Xbase {
+    Empty empty;
+    Y f();
+  };
+  struct Y : public X { 
+    Empty empty;
+  };
+  X getX();
+  int takeY(const Y&, int y);
+  void g() {
+    // rdar://8340348 - The temporary for the X object needs to have a defined
+    // address when passed into X::f as 'this'.
+    takeY(getX().f(), 42);
+  }
+  // CHECK: void @_ZN5test51gEv()
+  // CHECK: alloca %"struct.test5::Y"
+  // CHECK: alloca %"struct.test5::X"
+  // CHECK: alloca %"struct.test5::Y"
+}





More information about the cfe-commits mailing list