SILGen: Zero-initialize structs in constructors.

Otherwise we try to release junk pointers when we reassign class fields in the struct. Add an attribute to InitializeVarInst so that when dataflow analysis comes online, it knows that these InitializeVars need to be eliminated and can't be lowered to default constructor calls (since we're already in a constructor).

Swift SVN r4730
This commit is contained in:
Joe Groff
2013-04-13 20:45:18 +00:00
parent 700615e864
commit 8ee0fb4e96
6 changed files with 27 additions and 8 deletions

View File

@@ -445,15 +445,19 @@ class InitializeVarInst : public SILInstruction {
/// The address of the var to initialize.
Dest
};
bool CanDefaultConstruct;
FixedOperandList<1> Operands;
public:
InitializeVarInst(SILLocation Loc, SILValue Dest);
InitializeVarInst(SILLocation Loc, SILValue Dest, bool CanDefaultConstruct);
SILValue getDest() const { return Operands[Dest].get(); }
ArrayRef<Operand> getAllOperands() const { return Operands.asArray(); }
/// True if this InitializeVar can be lowered to a default constructor call.
bool canDefaultConstruct() const { return CanDefaultConstruct; }
static bool classof(const ValueBase *V) {
return V->getKind() == ValueKind::InitializeVarInst;
}