File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -3000,17 +3000,20 @@ bool toInPlaceConstruction(DLValue *lhs, Expression *rhs) {
30003000 return true ;
30013001 }
30023002 // and temporaries
3003- else if (isTemporaryVar (rhs)) {
3003+ else if (auto vd = isTemporaryVar (rhs)) {
30043004 Logger::println (" success, in-place-constructing temporary" );
3005- auto lhsLVal = DtoLVal (lhs);
3006- auto rhsLVal = DtoLVal (rhs);
3007- if (!llvm::isa<llvm::AllocaInst>(rhsLVal)) {
3008- error (rhs->loc , " lvalue of temporary is not an alloca, please "
3009- " file an LDC issue" );
3010- fatal ();
3011- }
3012- if (lhsLVal != rhsLVal)
3013- rhsLVal->replaceAllUsesWith (lhsLVal);
3005+ assert (!isSpecialRefVar (vd) && " Can this happen?" );
3006+
3007+ // evaluate lhs to an lvalue, the target address
3008+ auto lval = DtoLVal (lhs);
3009+
3010+ // pre-set the lvalue of the temporary to that address
3011+ getIrLocal (vd, true )->value = lval;
3012+ gIR ->DBuilder .EmitLocalVariable (lval, vd);
3013+
3014+ // evaluate rhs, constructing the pre-allocated temporary
3015+ toElem (rhs);
3016+
30143017 return true ;
30153018 }
30163019
You can’t perform that action at this time.
0 commit comments