comparison gen/llvmhelpers.cpp @ 1643:8f121883bce8

Apply patch from klickverbot. This is his 'proper fix' patch for bug #395.
author Kelly Wilson <wilsonk cpsc.ucalgary.ca>
date Mon, 08 Mar 2010 23:37:40 -0700
parents b0dfdd5f6006
children 40bd4a0d4870
comparison
equal deleted inserted replaced
1642:f49cb50c6064 1643:8f121883bce8
1570 return type; 1570 return type;
1571 #endif 1571 #endif
1572 } 1572 }
1573 1573
1574 ////////////////////////////////////////////////////////////////////////////////////////// 1574 //////////////////////////////////////////////////////////////////////////////////////////
1575
1576 LLValue* makeLValue(Loc& loc, DValue* value)
1577 {
1578 Type* valueType = value->getType();
1579 bool needsMemory;
1580 LLValue* valuePointer;
1581 if (value->isIm()) {
1582 valuePointer = value->getRVal();
1583 needsMemory = !DtoIsPassedByRef(valueType);
1584 }
1585 else if (DVarValue* var = value->isVar()) {
1586 valuePointer = value->getLVal();
1587 needsMemory = false;
1588 }
1589 else if (value->isConst()) {
1590 valuePointer = value->getRVal();
1591 needsMemory = true;
1592 }
1593 else {
1594 valuePointer = DtoAlloca(valueType, ".makelvaluetmp");
1595 DVarValue var(valueType, valuePointer);
1596 DtoAssign(loc, &var, value);
1597 needsMemory = false;
1598 }
1599
1600 if (needsMemory) {
1601 LLValue* tmp = DtoAlloca(valueType, ".makelvaluetmp");
1602 DtoStore(valuePointer, tmp);
1603 valuePointer = tmp;
1604 }
1605
1606 return valuePointer;
1607 }