]> granicus.if.org Git - clang/commitdiff
Revert r170806, "Fix some bugs where we would sometimes use 0, not -1, when emitting...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Fri, 21 Dec 2012 02:50:38 +0000 (02:50 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Fri, 21 Dec 2012 02:50:38 +0000 (02:50 +0000)
It broke stage2.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170835 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprScalar.cpp
test/CodeGenCXX/cxx0x-initializer-array.cpp

index 0c1e23965df27d4432cd3b925d00f31dd6aef5d1..c7f65bf42024e6394803499bf29026f360f3b32c 100644 (file)
@@ -931,7 +931,7 @@ AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV) {
   // FIXME: Are initializers affected by volatile?
   if (Dest.isZeroed() && isSimpleZero(E, CGF)) {
     // Storing "i32 0" to a zero'd memory location is a noop.
-  } else if (isa<ImplicitValueInitExpr>(E) || isa<CXXScalarValueInitExpr>(E)) {
+  } else if (isa<ImplicitValueInitExpr>(E)) {
     EmitNullInitializationToLValue(LV);
   } else if (type->isReferenceType()) {
     RValue RV = CGF.EmitReferenceBindingToExpr(E, /*InitializedDecl=*/0);
@@ -960,8 +960,8 @@ void AggExprEmitter::EmitNullInitializationToLValue(LValue lv) {
     return;
   
   if (!CGF.hasAggregateLLVMType(type)) {
-    // For non-aggregates, we can store the appropriate null constant.
-    llvm::Value *null = CGF.CGM.EmitNullConstant(type);
+    // For non-aggregates, we can store zero.
+    llvm::Value *null = llvm::Constant::getNullValue(CGF.ConvertType(type));
     // Note that the following is not equivalent to
     // EmitStoreThroughBitfieldLValue for ARC types.
     if (lv.isBitField()) {
index 69f6923963cfbb120dec2ba2804c7cd8661bbfbd..9071e693f9eb73d45be81c1fc93114b071caea05 100644 (file)
@@ -266,7 +266,7 @@ public:
   Value *VisitInitListExpr(InitListExpr *E);
 
   Value *VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E) {
-    return EmitNullValue(E->getType());
+    return CGF.CGM.EmitNullConstant(E->getType());
   }
   Value *VisitExplicitCastExpr(ExplicitCastExpr *E) {
     if (E->getType()->isVariablyModifiedType())
@@ -800,7 +800,10 @@ EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
 }
 
 Value *ScalarExprEmitter::EmitNullValue(QualType Ty) {
-  return CGF.CGM.EmitNullConstant(Ty);
+  if (const MemberPointerType *MPT = Ty->getAs<MemberPointerType>())
+    return CGF.CGM.getCXXABI().EmitNullMemberPointer(MPT);
+
+  return llvm::Constant::getNullValue(ConvertType(Ty));
 }
 
 /// \brief Emit a sanitization check for the given "binary" operation (which
index 5e81ba1ff9d88df75a9d797101360f2cec23e46d..df689978a889911b934c27b60ac1072fab5361e3 100644 (file)
@@ -1,7 +1,5 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
 
-// CHECK: @[[THREE_NULL_MEMPTRS:.*]] = private constant [3 x i32] [i32 -1, i32 -1, i32 -1]
-
 struct A { int a[1]; };
 typedef A x[];
 int f() {
@@ -9,42 +7,4 @@ int f() {
   // CHECK: define i32 @_Z1fv
   // CHECK: store i32 1
   // (It's okay if the output changes here, as long as we don't crash.)
-  return 0;
-}
-
-namespace ValueInitArrayOfMemPtr {
-  struct S {};
-  typedef int (S::*p);
-  typedef p a[3];
-  void f(const a &);
-
-  struct Agg1 {
-    int n;
-    p x;
-  };
-
-  struct Agg2 {
-    int n;
-    a x;
-  };
-
-  struct S1 {
-    p x;
-    S1();
-  };
-
-  // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1fEi
-  void f(int n) {
-    Agg1 a = { n };
-    // CHECK: store i32 -1,
-
-    Agg2 b = { n };
-    // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %{{.*}}, i8* bitcast ([3 x i32]* @[[THREE_NULL_MEMPTRS]] to i8*), i32 12, i32 4, i1 false)
-  }
-
-  // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1gEv
-  void g() {
-    // CHECK: store i32 -1,
-    f(a{});
-  }
 }