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-14750] Optimization error in sorting algorithm #57100

Open
typesanitizer opened this issue Jun 9, 2021 · 2 comments
Open

[SR-14750] Optimization error in sorting algorithm #57100

typesanitizer opened this issue Jun 9, 2021 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@typesanitizer
Copy link

Previous ID SR-14750
Radar rdar://45044610
Original Reporter @typesanitizer
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 4203b07931b73fd26e98cd063697a341

Issue Description:

Originally posted on radar, we should investigate if this issue is still present, and if not, remove the workarounds in Sort.swift .

When Swift is compiled with this new algorithm, running the attached Swift file crashes with this message:
      terminated by signal SIGILL (Illegal instruction)

Things Ive noticed in my investigation:

- The crash happens whenever the array to be sorted is 64 elements or greater, which is the cutoff for using the new merge sort
- No crash when run in debug mode
- No crash if I add a single print statement to the _merge(…) function instdlib/public/core/Sort.swift”
- No crash if I simplify the less-than operator implementation for Record (in the attached Swift file) to this:

    if lhs.last != rhs.last {
      return lhs.last < rhs.last
    }
    return lhs.first < rhs.first
@typesanitizer
Copy link
Author

@glessard
Copy link
Contributor

glessard commented Dec 8, 2021

The optimization error no longer appears to happen, but the portion of the workarounds that leaked into return values are now baked into ABI due to these functions being @usableFromInline.

(I tested a toolchain generated with #40081 post-5.5)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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
Projects
None yet
Development

No branches or pull requests

2 participants