[llvm-branch-commits] [cfe-branch] r119424 - in /cfe/branches/Apple/whitney: lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGValue.h test/CodeGenCXX/temporaries.cpp
Daniel Dunbar
daniel at zuster.org
Tue Nov 16 16:23:57 PST 2010
Author: ddunbar
Date: Tue Nov 16 18:23:57 2010
New Revision: 119424
URL: http://llvm.org/viewvc/llvm-project?rev=119424&view=rev
Log:
Merge r119408:
--
Author: John McCall <rjmccall at apple.com>
Date: Wed Nov 17 00:07:33 2010 +0000
Reset the lifetime-managed flag between emission of the agg conditional
branches. Fixes PR8623.
Modified:
cfe/branches/Apple/whitney/lib/CodeGen/CGExprAgg.cpp
cfe/branches/Apple/whitney/lib/CodeGen/CGValue.h
cfe/branches/Apple/whitney/test/CodeGenCXX/temporaries.cpp
Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGExprAgg.cpp?rev=119424&r1=119423&r2=119424&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGExprAgg.cpp Tue Nov 16 18:23:57 2010
@@ -396,8 +396,8 @@
CGF.BeginConditionalBranch();
CGF.EmitBlock(LHSBlock);
- // Handle the GNU extension for missing LHS.
- assert(E->getLHS() && "Must have LHS for aggregate value");
+ // Save whether the destination's lifetime is externally managed.
+ bool DestLifetimeManaged = Dest.isLifetimeExternallyManaged();
Visit(E->getLHS());
CGF.EndConditionalBranch();
@@ -406,6 +406,12 @@
CGF.BeginConditionalBranch();
CGF.EmitBlock(RHSBlock);
+ // If the result of an agg expression is unused, then the emission
+ // of the LHS might need to create a destination slot. That's fine
+ // with us, and we can safely emit the RHS into the same slot, but
+ // we shouldn't claim that its lifetime is externally managed.
+ Dest.setLifetimeExternallyManaged(DestLifetimeManaged);
+
Visit(E->getRHS());
CGF.EndConditionalBranch();
CGF.EmitBranch(ContBlock);
Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGValue.h?rev=119424&r1=119423&r2=119424&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGValue.h (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGValue.h Tue Nov 16 18:23:57 2010
@@ -379,8 +379,8 @@
bool isLifetimeExternallyManaged() const {
return LifetimeFlag;
}
- void setLifetimeExternallyManaged() {
- LifetimeFlag = true;
+ void setLifetimeExternallyManaged(bool Managed = true) {
+ LifetimeFlag = Managed;
}
bool isVolatile() const {
Modified: cfe/branches/Apple/whitney/test/CodeGenCXX/temporaries.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CodeGenCXX/temporaries.cpp?rev=119424&r1=119423&r2=119424&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/CodeGenCXX/temporaries.cpp (original)
+++ cfe/branches/Apple/whitney/test/CodeGenCXX/temporaries.cpp Tue Nov 16 18:23:57 2010
@@ -493,3 +493,35 @@
A(*x).foo();
}
}
+
+namespace PR8623 {
+ struct A { A(int); ~A(); };
+
+ // CHECK: define void @_ZN6PR86233fooEb(
+ void foo(bool b) {
+ // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align 1
+ // CHECK-NEXT: [[LCONS:%.*]] = alloca i1
+ // CHECK-NEXT: [[RCONS:%.*]] = alloca i1
+ // CHECK-NEXT: store i1 false, i1* [[RCONS]]
+ // CHECK-NEXT: store i1 false, i1* [[LCONS]]
+ // CHECK: br i1
+ // CHECK: call void @_ZN6PR86231AC1Ei([[A]]* [[TMP]], i32 2)
+ // CHECK-NEXT: store i1 true, i1* [[LCONS]]
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN6PR86231AC1Ei([[A]]* [[TMP]], i32 3)
+ // CHECK-NEXT: store i1 true, i1* [[RCONS]]
+ // CHECK-NEXT: br label
+ // CHECK: load i1* [[RCONS]]
+ // CHECK-NEXT: br i1
+ // CHECK: call void @_ZN6PR86231AD1Ev([[A]]* [[TMP]])
+ // CHECK-NEXT: store i1 false, i1* [[RCONS]]
+ // CHECK-NEXT: br label
+ // CHECK: load i1* [[LCONS]]
+ // CHECK-NEXT: br i1
+ // CHECK: call void @_ZN6PR86231AD1Ev([[A]]* [[TMP]])
+ // CHECK-NEXT: store i1 false, i1* [[LCONS]]
+ // CHECK-NEXT: br label
+ // CHECK: ret void
+ b ? A(2) : A(3);
+ }
+}
More information about the llvm-branch-commits
mailing list