mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user