Skip to content

Merge main 2023-02-11 #5284

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 139 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
60bf544
[docs] GettingStarted: Bump required CMake version for `--xcode` once…
AnthonyLatsis Feb 6, 2023
fc3ebd1
Partially re-enable some @_objcImpl tests
beccadax Feb 6, 2023
aaf497e
Add the test that I forgot to add in 3c976e9d79986de3bd6ecf313b1d746a…
gottesmm Feb 6, 2023
6ee695a
[CursorInfo] Implement a few expression references as solver-based
ahoppen Dec 2, 2022
fcc5d98
[CursorInfo] Deliver results from solver-based cursor info
ahoppen Feb 7, 2023
c1599fe
Add -swift-module-file frontend flag for explicit Swift module depend…
artemcm Feb 3, 2023
c989823
[Dependency Scanning] Specify dependency inputs of Swift module depen…
artemcm Feb 4, 2023
be3812d
[Dependency Scanning] Add swift dependency compile arguments required…
artemcm Feb 6, 2023
bf341ac
[cxx-interop] Require `begin()` and `end()` to be non-mutating for au…
egorzhdan Feb 7, 2023
e313c53
[ConstraintSystem] Teach `getCalleeLocator` about pattern matching
xedin Feb 7, 2023
f4e7e1c
[interop][SwiftToCxx] update external_source_symbol check for USR cla…
hyp Feb 7, 2023
183fc28
[benchmark] change a buffer length
glessard Feb 8, 2023
3b72951
[sil] Provide FieldSensitivePrunedLiveness with its own implementatio…
gottesmm Feb 6, 2023
d5aea69
[sil] Refactor field sensitive pruned liveness so it can be used with…
gottesmm Feb 7, 2023
a4985bf
[move-only] Change MoveOnlyBorrowToDestructureTransform into a driver…
gottesmm Feb 7, 2023
91686c0
[move-only] Refactor some helper structs out of BorrowToDestructureTr…
gottesmm Feb 7, 2023
bd81c0d
[move-only] Move header info for borrow to destructure transform into…
gottesmm Feb 7, 2023
4b6a87a
[move-only] Begin extracting out the impl of BorrowToDestructure from…
gottesmm Feb 7, 2023
c25d58d
[move-only] Refactor BorrowToDestructureTransform::gatherBorrows into…
gottesmm Feb 7, 2023
5d1fe77
[move-only] Move the rest of the actual computation from the borrowTo…
gottesmm Feb 7, 2023
69a1635
[move-only] Hide the AvailableValue impl used by BorrowToDestructureT…
gottesmm Feb 7, 2023
b244df0
[move-only][borrow2destructure] Sink liveness into the implementation…
gottesmm Feb 7, 2023
8391805
[move-only][borrow2destructure] Split cleanup code into the borrow sp…
gottesmm Feb 7, 2023
e9e704e
[move-only][borrow2destructure] Move destructureNeedingUses, instToIn…
gottesmm Feb 7, 2023
83dd93a
[CSGen] Handle recursive use of variable declarations
xedin Feb 7, 2023
f64e7d3
[NFC] Slightly loosen IR checks in objcImpl test
beccadax Feb 6, 2023
159c653
Add the tuple_pack_element_addr SIL instruction.
rjmccall Feb 8, 2023
6dca3e9
[AST] Fixed ::getReducedShape for SILPackType.
nate-chandler Feb 8, 2023
58954ab
[IRGen] Added getPackElementSize.
nate-chandler Feb 8, 2023
e2b22d9
[AST/Sema] Remove TypeWrapper feature functionality
xedin Feb 8, 2023
c5ff89a
Merge pull request #63476 from gottesmm/pr-fe1b2b5410a552e82f4eb980a0…
gottesmm Feb 8, 2023
68f9e84
Merge pull request #63492 from apple/egorzhdan/cxx-sequence-immutable
egorzhdan Feb 8, 2023
4ceec83
Merge pull request #63504 from hyp/eng/update-external-src-symbol-usr
hyp Feb 8, 2023
acd72ef
Merge pull request #63460 from artemcm/ExplicitDependenciesOnCommandLine
artemcm Feb 8, 2023
d2e022d
Remove linear map structs and use plain tuples instead. (#63444)
asl Feb 8, 2023
dcf90ba
Merge pull request #63512 from rjmccall/tuple_pack_element_addr
rjmccall Feb 8, 2023
d785202
IRGen: Change to using frame-pointer=non-leaf for functions that requ…
aschwaighofer Feb 8, 2023
e025a49
[interop] NFC, test, drop libcxx-in-sdk requirement
hyp Feb 8, 2023
61ab4d5
[Frontend] Remove TypeWrappers flag and associated attributes
xedin Feb 8, 2023
acb7f8e
Implement generic signature checking for PartialType.create(with:) (#…
Azoy Feb 8, 2023
e0bf2ff
[SIL/DI] NFC: Remove TypeWrappers feature functionality
xedin Feb 8, 2023
5dded3d
[Tests] NFC: Remove test-cases associated with TypeWrappers feature
xedin Feb 8, 2023
8305c7d
[interop][SwiftToCxx] add C++ bindings for static methods
hyp Feb 8, 2023
85ba74b
Introduce a separate feature to cover `@freestanding(expression)`
DougGregor Feb 8, 2023
01dc2d1
Merge pull request #63498 from xedin/rdar-105089074
xedin Feb 8, 2023
6e483db
Merge pull request #63520 from hyp/eng/drop-libcxx-in-sdk-req
hyp Feb 8, 2023
4ec36a4
Merge pull request #63509 from glessard/issue63200-benchmark-update
swift-ci Feb 8, 2023
0b0cc99
[interop][SwiftToCxx] avoid -Wshadow warning for C++ representation o…
hyp Feb 8, 2023
feceaa2
Fix bug during IR generation of a signed access
meg-gupta Feb 8, 2023
b70ba09
[interop][SwiftToCxx] remove extraneous ';' from generated header
hyp Feb 8, 2023
f487764
[move-only][borrow2destructure] Add support for processing switch_enum.
gottesmm Feb 7, 2023
e70a722
[move-only] Integrate BorrowToDestructureTransform into the AddressCh…
gottesmm Feb 7, 2023
a624fec
[move-only] Move MoveOnlyObjectChecker /before/ MoveOnlyAddressChecke…
gottesmm Feb 8, 2023
fbca92c
Merge pull request #63466 from apple/AnthonyLatsis-patch-1
AnthonyLatsis Feb 8, 2023
61b6383
[move-only] Now that borrow to destructure transform knows how to han…
gottesmm Feb 6, 2023
d56e169
[move-only] Fix up a test slightly.
gottesmm Feb 8, 2023
bf61578
[Macros] Don't assert when a macro parameter has a default argument
DougGregor Feb 8, 2023
2b13eca
Merge pull request #63510 from DougGregor/freestanding-expr-ast-printer
DougGregor Feb 8, 2023
0f4429b
DebugTypeInfo: Prefer the size of the Storage type derived from the T…
adrian-prantl Dec 16, 2022
2ebff4d
[GenTuple] Extracted dynamic tuple offset load.
nate-chandler Feb 8, 2023
74de34c
Round the initial context size of tasks up to 32 on 64-bit <=5.6 runt…
rjmccall Feb 8, 2023
956e81c
Add API to get the "outermost" parent source file.
DougGregor Feb 8, 2023
3d8e60d
Merge pull request #63523 from hyp/eng/i-static-methods
hyp Feb 8, 2023
31d8cad
Make objcImpl classes derive inherited inits
beccadax Feb 8, 2023
aa6ef50
Swap to an unprotected load to get better codegen
Azoy Feb 9, 2023
38e9af4
Move some tests into our testsuite and various other fixes
Azoy Feb 9, 2023
d9d8d56
Merge pull request #63529 from meg-gupta/fixptrauthcirdar
swift-ci Feb 9, 2023
c085f5a
Record original source range of generated source buffers into dumped …
DougGregor Feb 9, 2023
5666e1d
Merge pull request #63533 from DougGregor/minor-macro-fixes
DougGregor Feb 9, 2023
1bfb3e6
Merge pull request #62499 from adrian-prantl/102367872
swift-ci Feb 9, 2023
43c5824
Merge pull request #63524 from rjmccall/initial-context-size-compat-fix
rjmccall Feb 9, 2023
ae9e3a4
Swift SIL: fix base class of MarkUninitializedInst
eeckstein Feb 6, 2023
713f6c3
Swift SIL: add `Type.nominal` and `Type.isOrContainsObjectiveCClass` …
eeckstein Feb 3, 2023
b1c6ae6
Swift SIL: add metatype APIs to `Type`
eeckstein Feb 7, 2023
1c1d17e
Swift Optimizer: add some small optimization utilities
eeckstein Feb 3, 2023
67ed6cf
Swift Optimizer: add Simplification passes
eeckstein Feb 3, 2023
db10393
Passes.def: fix an outdated comment
eeckstein Feb 3, 2023
fc6f1d8
stdlib: make type comparison functions transparent
eeckstein Feb 3, 2023
0ff8663
SILLocation: fix location comparison for "FilenameAndLocation" locations
eeckstein Feb 7, 2023
e92f27c
Swift SIL: add some APIs to `Location`
eeckstein Feb 8, 2023
cef6ef9
SIL: add a debug_step instruction
eeckstein Feb 8, 2023
7eb2cb8
Swift Optimizer: add a pass to cleanup debug_step instructions
eeckstein Feb 8, 2023
f1c6ed6
Swift Optimizer: add Onone simplification of apply instructions
eeckstein Feb 6, 2023
3f35a1d
Swift Optimizer: add Onone simplification of branch instructions
eeckstein Feb 6, 2023
d56ed65
Swift Optimizer: add Onone simplification of some builtin instructions
eeckstein Feb 7, 2023
4cf6269
Swift Optimizer: add Onone simplification of cond_br instructions
eeckstein Feb 7, 2023
20edeb6
Swift Optimizer: add Onone simplification of unchecked_enum_data inst…
eeckstein Feb 7, 2023
1c70060
Swift Optimizer: add Onone simplification of struct_extract instructions
eeckstein Feb 7, 2023
85210a4
Swift Optimizer: make some SILCombine optimizations available for the…
eeckstein Feb 7, 2023
d25b1ed
Optimizer: Replace the MandatoryCombine pass with a Simplification pa…
eeckstein Feb 7, 2023
97b68be
Merge pull request #63530 from gottesmm/moveonly-enum-destructure
gottesmm Feb 9, 2023
df6677b
Merge pull request #63494 from eeckstein/instruction-passes
eeckstein Feb 9, 2023
85067a5
Merge pull request #63528 from hyp/eng/warning-fixes
hyp Feb 9, 2023
919eea7
[cxx-interop] Add `CxxDictionary` protocol for `std::map` ergonomics
egorzhdan Feb 7, 2023
88adc41
Merge pull request #63537 from DougGregor/source-loc-files-comments
DougGregor Feb 9, 2023
7acc339
[IRGen] Lowered tuple_pack_element_addr.
nate-chandler Feb 8, 2023
da5b5c1
[IRGen] Lowered de/alloc_pack.
nate-chandler Feb 8, 2023
11bcfd4
[Test] Mark test/stdlib/Reflection/PartialType.swift unsupported in f…
mikeash Feb 9, 2023
cd2d983
Merge pull request #63544 from mikeash/partialtype-unsupported-freest…
mikeash Feb 9, 2023
8546e43
Merge pull request #63518 from aschwaighofer/frame-pointer-non-leaf
aschwaighofer Feb 9, 2023
8eebb5b
Merge pull request #63522 from xedin/revert-type-wrappers
xedin Feb 9, 2023
a705ee2
[Build] Limit Ubuntu 18.04 LSAN CI to 12 link jobs
bnbarham Feb 9, 2023
f22d6d7
Merge pull request #63532 from nate-chandler/variadic-generics/irgen/…
swift-ci Feb 9, 2023
3b4d03c
Merge pull request #63513 from nate-chandler/variadic-generics/irgen/…
nate-chandler Feb 9, 2023
9751110
[Test] Loosened FileCheck lines for 32bit.
nate-chandler Feb 9, 2023
8a163ff
Limit the amount of parallelism on asan LLDB bots to nphyscpus/2
adrian-prantl Feb 9, 2023
b9cf9ad
Merge pull request #63497 from apple/egorzhdan/cxx-dictionary
egorzhdan Feb 9, 2023
9401926
Merge pull request #63505 from xedin/issue-63455
xedin Feb 9, 2023
7d93b75
Merge pull request #63534 from beccadax/default-is-not-init-stars
beccadax Feb 9, 2023
c3e62f9
Merge pull request #63546 from bnbarham/lsan-limit-link-jobs
bnbarham Feb 9, 2023
4705183
[Macros] Add plugin search paths to load plugin modules by name.
DougGregor Feb 9, 2023
a7e7007
Merge pull request #63548 from nate-chandler/rdar105226018
swift-ci Feb 9, 2023
e7ee839
[CursorInfo] A few miscellaneous fixes to the AST-based cursor info a…
ahoppen Feb 7, 2023
3e46063
[CursorInfo] Fix bug when performing solver-based cursor info on Self
ahoppen Feb 8, 2023
a9cba54
[CursorInfo] Fix a bug that caused solver-based cursor info to crash …
ahoppen Feb 8, 2023
ba3cc28
ABI Checker: avoid reporting module importation changes
nkcsgexi Feb 9, 2023
09b06a8
Revert "[Serialization] Enable deserialization safety by default"
xymus Jan 6, 2023
049d785
Add visitAccessPathBaseUses API
atrick Feb 9, 2023
084e4e1
Merge pull request #63549 from adrian-prantl/limit-asan-main
adrian-prantl Feb 9, 2023
62a6469
[Serialization] Move deserialization safety behind an env var or flag
xymus Feb 10, 2023
08c1d27
Merge pull request #63554 from nkcsgexi/abi-import
nkcsgexi Feb 10, 2023
b7007cb
[interop][SwiftToCxx] dispatch Swift class methods correctly using th…
hyp Feb 10, 2023
64ba69e
Merge pull request #63556 from atrick/new-access-base-visitor
gottesmm Feb 10, 2023
eb69afc
[SIL] Fix printing of type erased layout constraints (#63561)
drexin Feb 10, 2023
04eca73
[Macros] Stop parsing the ": <type>" syntax. We always require parame…
DougGregor Feb 10, 2023
fad0f90
Merge pull request #63558 from DougGregor/plugin-search-paths
DougGregor Feb 10, 2023
9985807
Merge pull request #63565 from DougGregor/macro-syntax-cleanup
DougGregor Feb 10, 2023
fd039f4
Merge pull request #62478 from ahoppen/ahoppen/solver-based-cursor-info
ahoppen Feb 10, 2023
75e4fe6
Merge pull request #63560 from hyp/eng/vtable1
hyp Feb 10, 2023
4edc241
Fix Lock and mark a few tests unsupported
Azoy Feb 10, 2023
13e1aa4
Add OwnershipLiveness utilities
atrick Feb 7, 2023
ff8f632
[Test] Temporarily disable failing test to unblock CI
bnbarham Feb 10, 2023
5033a73
Merge pull request #63575 from bnbarham/disable-new-sk-test
mikeash Feb 10, 2023
dbeff97
Merge pull request #63562 from xymus/disable-deserialization-safety
xymus Feb 10, 2023
72f9c3f
Merge pull request #63535 from Azoy/reflection-fixes
Azoy Feb 10, 2023
5523c56
Merge pull request #63404 from atrick/ossa-liveness
atrick Feb 11, 2023
9b66499
Merge remote-tracking branch 'origin/main' into katei/merge-main-2023…
kateinoigakukun Feb 11, 2023
0dcdeeb
[wasm] Enable SWIFT_ENABLE_EXPERIMENTAL_REFLECTION for stdlib to fix …
kateinoigakukun Feb 11, 2023
134fe4f
[wasm] XFAIL _Runtime tests for now
kateinoigakukun Feb 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

swift_compiler_sources(Optimizer
AssumeSingleThreaded.swift
CleanupDebugSteps.swift
ComputeEscapeEffects.swift
ComputeSideEffects.swift
ObjCBridgingOptimization.swift
MergeCondFails.swift
ReleaseDevirtualizer.swift
SimplificationPasses.swift
StackPromotion.swift
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//===--- SimplificationPasses.swift ----------------------------------------==//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import SIL

/// Removes redundant `debug_step` instructions.
/// If a `debug_step` has the same debug location as a previous or succeeding instruction
/// it is removed. It's just important that there is at least one instruction for a
/// certain debug location so that single stepping on that location will work.
let cleanupDebugStepsPass = FunctionPass(name: "cleanup-debug-steps") {
(function: Function, context: FunctionPassContext) in

for block in function.blocks {
cleanupDebugSteps(in: block, context)
}
}

private func cleanupDebugSteps(in block: BasicBlock, _ context: FunctionPassContext) {
var lastInstWithSameLocation: Instruction?

for inst in block.instructions {
if !inst.location.isDebugSteppable {
if inst is DebugStepInst && !inst.location.isDebugSteppable {
// First case: the instruction which is replaced by the debug_step didn't have a valid
// location itself. Then we don't need the debug_step either.
context.erase(instruction: inst)
}
continue
}

if let li = lastInstWithSameLocation,
!inst.location.hasSameSourceLocation(as: li.location) {
lastInstWithSameLocation = nil
}

// Only instructions which are really compiled down to some machine instructions can be
// single stepped on.
if !inst.producesMachineCode {
continue
}

if let li = lastInstWithSameLocation {
if inst is DebugStepInst {

// Second case:
// %li = some_instruction, loc "l"
// debug_step, loc "l" // current inst -> erase
context.erase(instruction: inst)
continue
} else if li is DebugStepInst {

// Third case:
// debug_step, loc "l" // li -> erase
// %inst = some_instruction, loc "l" // current inst
context.erase(instruction: li)
}
}
lastInstWithSameLocation = inst
}
}

private extension Instruction {
var producesMachineCode: Bool {
switch self {
// We could include more instructions here.
// In worst case a debug_step instruction remains in the code although it's not needed.
// This is harmless.
case is DebugStepInst, is ApplySite, is LoadInst, is StoreInst, is TermInst:
return location.isDebugSteppable
default:
return false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
//===--- SimplificationPasses.swift ----------------------------------------==//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import SIL

//===--------------------------------------------------------------------===//
// Instruction protocols
//===--------------------------------------------------------------------===//

/// Instructions which can be simplified at all optimization levels
protocol Simplifyable : Instruction {
func simplify(_ context: SimplifyContext)
}

/// Instructions which can be simplified at -Onone
protocol OnoneSimplifyable : Simplifyable {
}

/// Instructions which can only be simplified at the end of the -Onone pipeline
protocol LateOnoneSimplifyable : Instruction {
func simplifyLate(_ context: SimplifyContext)
}

//===--------------------------------------------------------------------===//
// Simplification passes
//===--------------------------------------------------------------------===//

let ononeSimplificationPass = FunctionPass(name: "onone-simplification") {
(function: Function, context: FunctionPassContext) in

runSimplification(on: function, context, preserveDebugInfo: true) {
if let i = $0 as? OnoneSimplifyable {
i.simplify($1)
}
}
}

let simplificationPass = FunctionPass(name: "simplification") {
(function: Function, context: FunctionPassContext) in

runSimplification(on: function, context, preserveDebugInfo: false) {
if let i = $0 as? Simplifyable {
i.simplify($1)
}
}
}

let lateOnoneSimplificationPass = FunctionPass(name: "late-onone-simplification") {
(function: Function, context: FunctionPassContext) in

runSimplification(on: function, context, preserveDebugInfo: true) {
if let i = $0 as? LateOnoneSimplifyable {
i.simplifyLate($1)
} else if let i = $0 as? OnoneSimplifyable {
i.simplify($1)
}
}
}

//===--------------------------------------------------------------------===//
// Pass implementation
//===--------------------------------------------------------------------===//


private func runSimplification(on function: Function, _ context: FunctionPassContext,
preserveDebugInfo: Bool,
_ simplify: (Instruction, SimplifyContext) -> ()) {
var worklist = InstructionWorklist(context)
defer { worklist.deinitialize() }

let simplifyCtxt = context.createSimplifyContext(preserveDebugInfo: preserveDebugInfo,
notifyInstructionChanged: {
worklist.pushIfNotVisited($0)
})

// Push in reverse order so that popping from the tail of the worklist visits instruction in forward order again.
worklist.pushIfNotVisited(contentsOf: function.reversedInstructions)

// Run multiple iterations because cleanupDeadCode can add new candidates to the worklist.
repeat {

// The core worklist-loop.
while let instruction = worklist.popAndForget() {
if instruction.isDeleted {
continue
}
if !context.options.enableSimplification(for: instruction) {
continue
}
if !context.continueWithNextSubpassRun(for: instruction) {
return
}
simplify(instruction, simplifyCtxt)
}

cleanupDeadInstructions(in: function, preserveDebugInfo, context)
cleanupDeadBlocks(in: function, pushNewCandidatesTo: &worklist, context)

} while !worklist.isEmpty

if context.needFixStackNesting {
function.fixStackNesting(context)
}
}

private func cleanupDeadInstructions(in function: Function,
_ preserveDebugInfo: Bool,
_ context: FunctionPassContext) {
if preserveDebugInfo {
context.removeTriviallyDeadInstructionsPreservingDebugInfo(in: function)
} else {
context.removeTriviallyDeadInstructionsIgnoringDebugUses(in: function)
}
}

private func cleanupDeadBlocks(in function: Function,
pushNewCandidatesTo worklist: inout InstructionWorklist,
_ context: FunctionPassContext) {
if context.removeDeadBlocks(in: function) {
// After deleting dead blocks their (still alive) successor blocks may become eligible for block merging.
// Therefore we re-run simplification for all branch instructions.
for block in function.blocks.reversed() {
if let bi = block.terminator as? BranchInst {
worklist.pushIfNotVisited(bi)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

swift_compiler_sources(Optimizer
SimplifyApply.swift
SimplifyBeginCOWMutation.swift
SimplifyBranch.swift
SimplifyBuiltin.swift
SimplifyCondBranch.swift
SimplifyGlobalValue.swift
SimplifyStrongRetainRelease.swift)
SimplifyStrongRetainRelease.swift
SimplifyStructExtract.swift
SimplifyUncheckedEnumData.swift)
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//===--- SimplifyApply.swift ----------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import SIL

extension ApplyInst : OnoneSimplifyable {
func simplify(_ context: SimplifyContext) {
tryReplaceTrivialApplyOfPartialApply(context)
}
}

private extension ApplyInst {
func tryReplaceTrivialApplyOfPartialApply(_ context: SimplifyContext) {
guard let pa = callee as? PartialApplyInst else {
return
}

if pa.referencedFunction == nil {
return
}

// Currently we don't handle generic closures. For Onone this is good enough.
// TODO: handle it once we replace the SILCombine simplification with this.
if !allArgumentsAreTrivial(arguments) {
return
}

if !allArgumentsAreTrivial(pa.arguments) {
return
}

if !substitutionMap.isEmpty {
return
}

let allArgs = Array<Value>(arguments) + Array<Value>(pa.arguments)
let builder = Builder(before: self, context)
let newApply = builder.createApply(function: pa.callee, pa.substitutionMap, arguments: allArgs,
isNonThrowing: isNonThrowing, isNonAsync: isNonAsync,
specializationInfo: specializationInfo)
uses.replaceAll(with: newApply, context)
context.erase(instruction: self)

if context.tryDeleteDeadClosure(closure: pa) {
context.notifyInvalidatedStackNesting()
}
}
}

private func allArgumentsAreTrivial(_ args: LazyMapSequence<OperandArray, Value>) -> Bool {
return !args.contains { !$0.hasTrivialType }
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import SIL

extension BeginCOWMutationInst : SILCombineSimplifyable {
extension BeginCOWMutationInst : Simplifyable, SILCombineSimplifyable {
func simplify(_ context: SimplifyContext) {

/// The buffer of an empty Array/Set/Dictionary singleton is known to be not
Expand Down
Loading