Skip to content

[SILOpt] Disabled DestroyHoisting. #41478

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
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
14 changes: 8 additions & 6 deletions benchmark/single-source/SubstringTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,23 @@ public func run_SubstringFromLongStringGeneric(_ n: Int) {
}
}

@inline(never)
public func run_StringFromLongWholeSubstring(_ n: Int) {
private func getLongWideRealBuffer() -> String {
var s0 = longWide
s0 += "!" // ensure the string has a real buffer
let s = Substring(s0)
return s0
}

@inline(never)
public func run_StringFromLongWholeSubstring(_ n: Int) {
let s = Substring(getLongWideRealBuffer())
for _ in 1...n*500 {
blackHole(String(s))
}
}

@inline(never)
public func run_StringFromLongWholeSubstringGeneric(_ n: Int) {
var s0 = longWide
s0 += "!" // ensure the string has a real buffer
let s = Substring(s0)
let s = Substring(getLongWideRealBuffer())
for _ in 1...n*500 {
create(String.self, from: s)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/PassManager/PassPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ llvm::cl::opt<bool> SILDisableLateOMEByDefault(
"Disable late OME for non-transparent functions by default"));

llvm::cl::opt<bool>
EnableDestroyHoisting("enable-destroy-hoisting", llvm::cl::init(true),
EnableDestroyHoisting("enable-destroy-hoisting", llvm::cl::init(false),
llvm::cl::desc("Enable the DestroyHoisting pass."));

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Transforms/SSADestroyHoisting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class DeinitBarriers {
// sure not to hoist a destroy_addr into an access scope and by doing so cause
// a deinit which had previously executed outside an access scope to start
// executing within it--that could violate exclusivity.
llvm::SmallPtrSet<BeginAccessInst *, 8> barrierAccessScopes;
SmallPtrSet<BeginAccessInst *, 8> barrierAccessScopes;

explicit DeinitBarriers(bool ignoreDeinitBarriers,
const KnownStorageUses &knownUses,
Expand Down
5 changes: 3 additions & 2 deletions test/SILOptimizer/assemblyvision_remark/chacha.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public func run_ChaCha(_ N: Int) {

var checkedtext = Array(repeating: UInt8(0), count: 1024)
ChaCha20.encrypt(bytes: &checkedtext, key: key, nonce: nonce)
checkResult(checkedtext) // expected-remark {{release of type '}}
// expected-note @-3 {{of 'checkedtext}}
checkResult(checkedtext)// expected-note @-2 {{of 'checkedtext}}


var plaintext = Array(repeating: UInt8(0), count: 30720)
for _ in 1...N {
Expand All @@ -47,3 +47,4 @@ public func run_ChaCha(_ N: Int) {
// expected-note @-16 {{of 'nonce}}
// expected-remark @-4 {{release of type '}}
// expected-note @-19 {{of 'key}}
// expected-remark @-6 {{release of type '}}
1 change: 1 addition & 0 deletions test/SILOptimizer/enum_payload_modification_opt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// RUN: %target-run %t/a.out | %FileCheck %s

// REQUIRES: executable_test,swift_stdlib_no_asserts,optimized_stdlib
// REQUIRES: rdar89260664

final class Storage {
var v : Int
Expand Down
6 changes: 3 additions & 3 deletions test/SILOptimizer/hoist_destroy_addr.sil
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,12 @@ exit:

// Hoist a destroy_addr of an @in argument over a load from an alloc_stack.
//
// CHECK-LABEL: sil [ossa] @test_hoist_over_load_from_stack : {{.*}} {
// CHECK-LABEL: sil [ossa] @hoist_over_load_from_stack : {{.*}} {
// CHECK: apply
// CHECK: destroy_addr
// CHECK: load [take]
// CHECK-LABEL: } // end sil function 'test_hoist_over_load_from_stack'
sil [ossa] @test_hoist_over_load_from_stack : $@convention(thin) (@in X) -> @owned X {
// CHECK-LABEL: } // end sil function 'hoist_over_load_from_stack'
sil [ossa] @hoist_over_load_from_stack : $@convention(thin) (@in X) -> @owned X {
entry(%in_addr : $*X):
%stack_addr = alloc_stack $X
copy_addr %in_addr to [initialization] %stack_addr : $*X
Expand Down
4 changes: 0 additions & 4 deletions test/SILOptimizer/pointer_conversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ public func testMutableArray() {
// CHECK: [[POINTER:%.+]] = struct $UnsafeMutableRawPointer (
// CHECK-NEXT: [[DEP_POINTER:%.+]] = mark_dependence [[POINTER]] : $UnsafeMutableRawPointer on {{.*}} : $__ContiguousArrayStorageBase
// CHECK: [[FN:%.+]] = function_ref @takesMutableRawPointer
// CHECK: strong_retain {{%.+}} : ${{Builtin[.]BridgeObject|__ContiguousArrayStorageBase}}
// CHECK: apply [[FN]]([[DEP_POINTER]])
// CHECK-NOT: {{^bb[0-9]+:}}
// CHECK: strong_release {{%.+}} : ${{Builtin[.]BridgeObject|__ContiguousArrayStorageBase}}
// CHECK: strong_release {{%.+}} : ${{Builtin[.]BridgeObject|__ContiguousArrayStorageBase}}
// CHECK: dealloc_stack {{%.+}} : $*Array<Int>
// CHECK-NEXT: [[EMPTY:%.+]] = tuple ()
// CHECK-NEXT: return [[EMPTY]]
Expand All @@ -76,11 +74,9 @@ public func testMutableArrayToOptional() {
// CHECK-NEXT: [[DEP_POINTER:%.+]] = mark_dependence [[POINTER]] : $UnsafeMutableRawPointer on {{.*}} : $__ContiguousArrayStorageBase
// CHECK-NEXT: [[OPT_POINTER:%.+]] = enum $Optional<UnsafeMutableRawPointer>, #Optional.some!enumelt, [[DEP_POINTER]]
// CHECK: [[FN:%.+]] = function_ref @takesOptMutableRawPointer
// CHECK: strong_retain {{%.+}} : ${{Builtin[.]BridgeObject|__ContiguousArrayStorageBase}}
// CHECK: apply [[FN]]([[OPT_POINTER]])
// CHECK-NOT: {{^bb[0-9]+:}}
// CHECK: strong_release {{%.+}} : ${{Builtin[.]BridgeObject|__ContiguousArrayStorageBase}}
// CHECK: strong_release {{%.+}} : ${{Builtin[.]BridgeObject|__ContiguousArrayStorageBase}}
// CHECK: dealloc_stack {{%.+}} : $*Array<Int>
// CHECK-NEXT: [[EMPTY:%.+]] = tuple ()
// CHECK-NEXT: return [[EMPTY]]
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/templvalueopt.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -module-name=test -O -emit-sil %s | %FileCheck %s
// RUN: %target-swift-frontend -module-name=test -O -enable-ossa-modules -emit-sil %s | %FileCheck %s

// RUN: %empty-directory(%t)
// RUN: %target-build-swift -O -module-name=test %s -o %t/a.out
Expand Down
2 changes: 1 addition & 1 deletion validation-test/SILOptimizer/lexical-lifetimes.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -parse-as-library -Xfrontend -enable-copy-propagation -Xllvm -enable-destroy-hoisting=false) | %FileCheck %s
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -parse-as-library -Xfrontend -enable-copy-propagation) | %FileCheck %s

// REQUIRES: executable_test
// REQUIRES: concurrency
Expand Down