Skip to content

Lower move-only wrapper types earlier to disable the TrivialMoveOnlyTypeEliminator pass. #71538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/SILOptimizer/PassManager/PassPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,22 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
if (EnableDeinitDevirtualizer)
P.addDeinitDevirtualizer();

// FIXME: rdar://122701694 (`consuming` keyword causes verification error on
// invalid SIL types)
//
// Lower move only wrapped trivial types.
P.addTrivialMoveOnlyTypeEliminator();
// P.addTrivialMoveOnlyTypeEliminator();

// Check no uses after consume operator of a value in an address.
P.addConsumeOperatorCopyableAddressesChecker();
// No uses after consume operator of copyable value.
P.addConsumeOperatorCopyableValuesChecker();

// As a temporary measure, we also eliminate move only for non-trivial types
// until we can audit the later part of the pipeline. Eventually, this should
// occur before IRGen.
P.addMoveOnlyTypeEliminator();

//
// End Ownership Optimizations
//===---
Expand Down Expand Up @@ -246,11 +255,6 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
// Canonical swift requires all non cond_br critical edges to be split.
P.addSplitNonCondBrCriticalEdges();

// As a temporary measure, we also eliminate move only for non-trivial types
// until we can audit the later part of the pipeline. Eventually, this should
// occur before IRGen.
P.addMoveOnlyTypeEliminator();

// For embedded Swift: Specialize generic class vtables.
P.addVTableSpecializer();

Expand Down
5 changes: 5 additions & 0 deletions test/SILOptimizer/noimplicitcopy_consuming_parameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Klass {

public struct NonTrivialStruct {
var k = Klass()
let i = 0

func doSomethingDefault() {}
borrowing func doSomethingBorrowing() {}
Expand Down Expand Up @@ -230,6 +231,10 @@ func testLoadableConsumingCopyOperator(_ x: consuming NonTrivialStruct) {
_ = copy x
}

func testLoadableConsumingTrivialLetField(_ x: consuming NonTrivialStruct) -> Int {
return x.i
}

//////////////////////////////////////////
// MARK: Trivial Struct Consuming Tests //
//////////////////////////////////////////
Expand Down