mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CopyPropagation] Delete dead copy_values.
When canonicalizing an owned value's lifetime, also check whether the value is dead. If it is, track it for deletion. In particular, this eliminates dead copy_values.
This commit is contained in:
@@ -559,6 +559,9 @@ void CopyPropagation::run() {
|
||||
while (!defWorklist.ownedValues.empty()) {
|
||||
SILValue def = defWorklist.ownedValues.pop_back_val();
|
||||
canonicalizer.canonicalizeValueLifetime(def);
|
||||
// Copies of borrowed values may be dead.
|
||||
if (auto *inst = def->getDefiningInstruction())
|
||||
deleter.trackIfDead(inst);
|
||||
}
|
||||
// Recursively cleanup dead defs after removing uses.
|
||||
deleter.cleanupDeadInstructions();
|
||||
|
||||
Reference in New Issue
Block a user