mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CopyPropagation] Only delete if canonicalized.
Owned lifetime canonicalization bails on move-only values. Previously, though, every value that was fed to canonicalization was then attempted to be deleted. For dead move-only values, the result could be to shorten move-only lifetimes, which is illegal per language rules. Here, this is fixed by not attempting to delete owned values for which canonicalization bailed. rdar://114323803
This commit is contained in:
@@ -617,7 +617,9 @@ void CopyPropagation::run() {
|
||||
// Canonicalize all owned defs.
|
||||
while (!defWorklist.ownedValues.empty()) {
|
||||
SILValue def = defWorklist.ownedValues.pop_back_val();
|
||||
canonicalizer.canonicalizeValueLifetime(def);
|
||||
auto canonicalized = canonicalizer.canonicalizeValueLifetime(def);
|
||||
if (!canonicalized)
|
||||
continue;
|
||||
// Copies of borrowed values may be dead.
|
||||
if (auto *inst = def->getDefiningInstruction())
|
||||
deleter.trackIfDead(inst);
|
||||
|
||||
Reference in New Issue
Block a user