mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
LetPropertyLowering: remove redundant phis after ssa-update
This is needed after running the SSAUpdater, because the updater can insert unnecessary phis in the middle of the original liverange of a value. Fixes an ownership error. rdar://153229472
This commit is contained in:
@@ -122,6 +122,8 @@ private func insertEndInitInstructions(
|
||||
use.set(to: ssaUpdater.getValue(atEndOf: use.instruction.parentBlock), context)
|
||||
}
|
||||
}
|
||||
// This peephole optimization is required to avoid ownership errors.
|
||||
replacePhisWithIncomingValues(phis: ssaUpdater.insertedPhis, context)
|
||||
}
|
||||
|
||||
private func constructLetInitRegion(
|
||||
|
||||
@@ -311,3 +311,34 @@ bb1(%3a : @reborrow $C):
|
||||
return %2 : $C
|
||||
}
|
||||
|
||||
|
||||
// CHECK-LABEL: sil [ossa] @test_no_phis :
|
||||
// CHECK: %3 = end_init_let_ref %2
|
||||
// CHECK: return %3
|
||||
// CHECK: } // end sil function 'test_no_phis'
|
||||
sil [ossa] @test_no_phis : $@convention(thin) (Int, @owned C) -> @owned C {
|
||||
bb0(%0 : $Int, %1 : @owned $C):
|
||||
%2 = mark_uninitialized [rootself] %1
|
||||
%3 = begin_borrow %2
|
||||
cond_br undef, bb1, bb2
|
||||
bb1:
|
||||
br bb7
|
||||
bb2:
|
||||
cond_br undef, bb3, bb8
|
||||
bb3:
|
||||
cond_br undef, bb4, bb5
|
||||
bb4:
|
||||
br bb7
|
||||
bb5:
|
||||
br bb6
|
||||
bb6:
|
||||
end_borrow %3
|
||||
return %2
|
||||
bb7:
|
||||
br bb6
|
||||
bb8:
|
||||
end_borrow %3
|
||||
destroy_value [dead_end] %2
|
||||
unreachable
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user