]> granicus.if.org Git - clang/commitdiff
Slight optimization enabled by the previous assert:
authorJohn McCall <rjmccall@apple.com>
Fri, 26 Aug 2011 21:08:13 +0000 (21:08 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 26 Aug 2011 21:08:13 +0000 (21:08 +0000)
emit all gl-value arguments as reference bindings.

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

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGExpr.cpp
test/CodeGenObjCXX/arc-references.mm

index 102793b48ab8f44966c0f568b826df990fab45da..f7cb5492a8f6bfcc2b6a7a1888d0bb57b99a4903 100644 (file)
@@ -1434,9 +1434,11 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
   assert(type->isReferenceType() == E->isGLValue() &&
          "reference binding to unmaterialized r-value!");
 
-  if (type->isReferenceType())
+  if (E->isGLValue()) {
+    assert(E->getObjectKind() == OK_Ordinary);
     return args.add(EmitReferenceBindingToExpr(E, /*InitializedDecl=*/0),
                     type);
+  }
 
   if (hasAggregateLLVMType(type) && !E->getType()->isAnyComplexType() &&
       isa<ImplicitCastExpr>(E) &&
index 59b8fefb495c9c08a65147e97dacae5eea5ae809..d26d787da693755e5da929b69d41d451e909679f 100644 (file)
@@ -2150,8 +2150,7 @@ LValue CodeGenFunction::EmitOpaqueValueLValue(const OpaqueValueExpr *e) {
 
 LValue CodeGenFunction::EmitMaterializeTemporaryExpr(
                                            const MaterializeTemporaryExpr *E) {
-  RValue RV = EmitReferenceBindingToExpr(E->GetTemporaryExpr(),
-                                         /*InitializedDecl=*/0);
+  RValue RV = EmitReferenceBindingToExpr(E, /*InitializedDecl=*/0);
   return MakeAddrLValue(RV.getScalarVal(), E->getType());
 }
 
index 3d0313d13ac82e1fce4000533c6b8e7b9d913b92..b1a12e4511f47f9d98952834096afe39eaee74fd 100644 (file)
@@ -61,8 +61,9 @@ void sink(__strong A* &&);
 
 // CHECK: define void @_Z5test5RU8__strongP11objc_object
 void test5(__strong id &x) {
-  // CHECK: [[OBJ_ID:%[a-zA-Z0-9]+]] = call i8* @objc_retain
-  // CHECK-NEXT: [[OBJ_A:%[a-zA-Z0-9]+]] = bitcast i8* [[OBJ_ID]] to [[A:%[a-zA-Z0-9]+]]*
+  // CHECK:      [[REFTMP:%.*]] = alloca {{%.*}}*, align 8
+  // CHECK:      [[OBJ_ID:%.*]] = call i8* @objc_retain(
+  // CHECK-NEXT: [[OBJ_A:%.*]] = bitcast i8* [[OBJ_ID]] to [[A:%[a-zA-Z0-9]+]]*
   // CHECK-NEXT: store [[A]]* [[OBJ_A]], [[A]]** [[REFTMP:%[a-zA-Z0-9]+]]
   // CHECK-NEXT: call void @_Z4sinkOU8__strongP1A
   sink(x);