Skip to content
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

[SR-3074] When call direct call of generic function is 30x slower than indirect call #45664

Open
krzyzanowskim opened this issue Oct 28, 2016 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software performance

Comments

@krzyzanowskim
Copy link
Contributor

Previous ID SR-3074
Radar None
Original Reporter @krzyzanowskim
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, Performance
Assignee None
Priority Medium

md5: 37a90ca57b69b7234d6a6ac8081ade13

Issue Description:

I have this generic function

public func update<T: Sequence>(withBytes bytes: T) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
//...
}

when called directly it's slow

Foo().update(withBytes: [1,2,3])

when called indirectly, it's fast

func helper(bytes: Array<UInt8>) {
    Foo().update(withBytes: bytes)
}

helper(bytes: [1,2,3])

when tried add

@_specialize(Array<UInt8>) to "update()", swiftc crash.

0 swift 0x0000000108912a3d PrintStackTraceSignalHandler(void*) + 45
1 swift 0x0000000108912466 SignalHandler(int) + 470
2 libsystem_platform.dylib 0x00007fff808da52a _sigtramp + 26
3 libsystem_platform.dylib 0x00007febcdbb2308 _sigtramp + 1294827000
4 swift 0x0000000105ff828d swift::SILPassManager::runOneIteration() + 8749
5 swift 0x0000000105ffc776 swift::runSILOptimizationPasses(swift::SILModule&) + 3462
6 swift 0x0000000105cbfe15 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 20117
7 swift 0x0000000105cb8f70 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17856
8 swift 0x0000000105c7593e main + 8302
9 libdyld.dylib 0x00007fff885375ad start + 1
10 libdyld.dylib 0x00000000000000fc start + 2007796560

Stack dump:
0. Program arguments: .....

  1. While running pass Remove unnecessary unsafeUnwrap calls. #2 SILModuleTransform "Eager Specializer".
@Dante-Broggi
Copy link
Contributor

What should happen with this report?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software performance
Projects
None yet
Development

No branches or pull requests

3 participants