Skip to content

swiftc crash with certain input and optimizations #84692

@awwright

Description

@awwright

Description

There seems to be a problem while optimizing the hasher in this particular source block, but only when building in Release mode, or swiftc -O

Reproduction

$ swiftc -O input.swift

extension Array: Comparable where Element: Comparable {
	public static func < (lhs: Array<Element>, rhs: Array<Element>) -> Bool {
		// Contents do not matter
		for (l, r) in zip(lhs, rhs) { if l != r { return l < r } }
		return lhs.count < rhs.count
	}
}

struct Wrapper<Symbol: Hashable & Comparable>: Hashable {
	var partitions: PartitionSet<Array<Symbol>>
}

public struct PartitionSet<Symbol: Hashable & Comparable>: Equatable, Hashable {
	public var partitions: Set<Set<Symbol>>
}

Stack dump

0.	Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file input.swift -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk -color-diagnostics -Xcc -fcolor-diagnostics -O -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -no-auto-bridging-header-chaining -module-name input -disable-clang-spi -target-sdk-version 26.0 -target-sdk-name macosx26.0 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -in-process-plugin-server-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -enable-default-cmo -o /var/folders/v1/025rx9255xjfydft1w0mqr000000gn/T/TemporaryDirectory.NtkOjW/input-1.o
1.	Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
2.	Compiling with effective version 5.10
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for input)
4.	While running pass #1295 SILFunctionTransform "EarlyPerfInliner" on SILFunction "@$s5input7WrapperV4hash4intoys6HasherVz_tF".
 for 'hash(into:)' (in module 'input')
5.	While inlining SIL function "@$ss6HasherV7combineyyxSHRzlF".
 for 'combine(_:)' (in module 'Swift')
6.	While ...into SIL function "@$s5input7WrapperV4hash4intoys6HasherVz_tF".
 for 'hash(into:)' (in module 'input')

Expected behavior

Same behavior as swiftc by itself (no -O flag); source compiles, exit code 0.

Environment

swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
Target: arm64-apple-macosx15.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions