swift
[OSSACanonicalizeOwned] Fix liveness passed to completion.
#78624
Merged

[OSSACanonicalizeOwned] Fix liveness passed to completion. #78624

nate-chandler
nate-chandler158 days ago

To determine where a lifetime ends within dead-end blocks, OSSACanonicalizeOwned uses OSSACompleteLifetime's visitAvailabilityBoundary. This API takes a liveness which it uses to walk forward to the availability boundary. Specifically, the liveness passed from OSSACanonicalizeOwned to OSSACompleteLifetime is a variation of OSSACanonicalizeOwned's own liveness (it has destroys added).

There is a mismatch in the characteristics of livenesses created by OSSACanonicalizeOwned and OSSACompleteLifetime: The former deals with not only direct uses of a value but also uses of its copies; that introduces the possibility for consuming uses in the middle of liveness. The latter on the other hand deals only with uses of a single value (nestedly, but at each level of nesting only a single value). Passing a liveness from the former to the latter without handling this mismatch is incorrect: OSSACompleteLifetime understands consuming uses to always end a lifetime, even when they are in the middle of a copy-extended liveness. The result is that OSSACompleteLifetime produces non-sensical results when provided with such a liveness.

To address this, fixup the liveness passed from OSSACanonicalizeOwned to OSSACompleteLifetime by demoting consuming uses that appear within (that's to say not on the boundary) of liveness to non-consuming uses.

Also, check in a few other changes that facilitated tracking this down:

  • printing AST types when printing the SIL module when passing -sil-print-module-on-error
  • a minor refactoring to SILCombine to extract the processing it does on a single instruction into a separate function
  • a FunctionTest to call that new SILCombine function

rdar://142846936

nate-chandler [SIL] Print AST types with print-module-on-error.
9f87e0a8
nate-chandler [NFC] SILCombine: Ennamespace canonicalize class.
afe95135
nate-chandler [NFC] SILCombine: Extract processing function.
5ce6c6cf
nate-chandler [Test] Renamed test case.
6deba027
nate-chandler [Test] Added test for SILCombiner::processInst.
af5cd31f
nate-chandler [NFC] PrunedLiveness: Permit postDomBlocks dupes.
4135540f
nate-chandler nate-chandler force pushed from af23ca0d to 30024b34 158 days ago
nate-chandler nate-chandler force pushed from 30024b34 to 4f8cf611 158 days ago
nate-chandler
nate-chandler157 days ago

Source compat failures match failures in baseline.

nate-chandler nate-chandler requested a review from eeckstein eeckstein 157 days ago
nate-chandler nate-chandler requested a review from meg-gupta meg-gupta 157 days ago
nate-chandler nate-chandler requested a review from atrick atrick 157 days ago
nate-chandler nate-chandler marked this pull request as ready for review 157 days ago
nate-chandler nate-chandler requested a review from jckarter jckarter 157 days ago
nate-chandler nate-chandler removed review request from jckarter jckarter 157 days ago
nate-chandler nate-chandler force pushed from 4f8cf611 to 6a2fadca 156 days ago
nate-chandler [OSSACanOwned] Fix liveness passed to completion.
ebf60280
nate-chandler nate-chandler force pushed from 6a2fadca to ebf60280 156 days ago
nate-chandler
nate-chandler156 days ago

@swift-ci please test

nate-chandler
nate-chandler156 days ago

@swift-ci please apple silicon benchmark

nate-chandler
nate-chandler156 days ago

@swift-ci please test source compatibility

nate-chandler
nate-chandler156 days ago

@swift-ci please test macos platform

atrick
atrick approved these changes on 2025-01-15
atrick156 days ago

LGTM

nate-chandler nate-chandler merged b59280c0 into main 156 days ago
nate-chandler nate-chandler deleted the rdar142520491_2 branch 156 days ago

Login to write a write a comment.

Login via GitHub

Assignees
No one assigned
Labels
Milestone