Files
swift-mirror/SwiftCompilerSources/Sources/Optimizer/PassManager/Options.swift
Erik Eckstein 16cb80b60d Optimizer: implement all of cond_fail simplification as instruction simplification
Inserts an unreachable after an unconditional fail:
```
  %0 = integer_literal 1
  cond_fail %0, "message"
  // following instructions
```
->
```
  %0 = integer_literal 1
  cond_fail %0, "message"
  unreachable
deadblock:
  // following instructions
```

Remove the old SILCombine implementation because it's not working well with OSSA lifetime completion.
This also required to move the `shouldRemoveCondFail` utility function from SILCombine to InstOptUtils.
2026-01-22 17:41:22 +01:00

92 lines
2.3 KiB
Swift

//===--- Options.swift ----------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2022 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
import OptimizerBridging
struct Options {
let _bridged: BridgedPassContext
var enableStackProtection: Bool {
_bridged.enableStackProtection()
}
var useAggressiveReg2MemForCodeSize : Bool {
_bridged.useAggressiveReg2MemForCodeSize()
}
var enableMoveInoutStackProtection: Bool {
_bridged.enableMoveInoutStackProtection()
}
func enableSimplification(for inst: Instruction) -> Bool {
_bridged.enableSimplificationFor(inst.bridged)
}
func enableAddressDependencies() -> Bool {
_bridged.enableAddressDependencies()
}
var noAllocations: Bool {
_bridged.noAllocations()
}
var enableEmbeddedSwift: Bool {
hasFeature(.Embedded)
}
var enableEmbeddedSwiftExistentials: Bool {
hasFeature(.Embedded) && hasFeature(.EmbeddedExistentials)
}
var enableMergeableTraps: Bool {
_bridged.enableMergeableTraps()
}
func hasFeature(_ feature: BridgedFeature) -> Bool {
_bridged.hasFeature(feature)
}
func shouldRemoveCondFail(withMessage message: StringRef, inFunction: StringRef) -> Bool {
_bridged.shouldRemoveCondFail(message._bridged, inFunction._bridged)
}
// The values for the assert_configuration call are:
// 0: Debug
// 1: Release
// 2: Fast / Unchecked
enum AssertConfiguration {
case debug
case release
case unchecked
case unknown
var integerValue: Int {
switch self {
case .debug: return 0
case .release: return 1
case .unchecked: return 2
case .unknown: fatalError()
}
}
}
var assertConfiguration: AssertConfiguration {
switch _bridged.getAssertConfiguration() {
case .Debug: return .debug
case .Release: return .release
case .Unchecked: return .unchecked
default: return .unknown
}
}
}