-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Use builtins instead of shims in FloatingPointTypes. #3454
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
Use builtins instead of shims in FloatingPointTypes. #3454
Conversation
Don't the LLVM intrinsics have different semantics from the C functions in some cases? Are there differences we care about? (Not setting |
@jckarter So they're all defined to do the right thing except for |
Dunno, is the backend smart enough to do the right thing if you write the test-and- |
Doesn't appear to do so for something like this, alas: declare double @llvm.sqrt.f64(double %x)
define double @sqrtOrNaN(double %x) {
entry:
%z = fcmp ult double %x, 0.0
%b = call double @llvm.sqrt.f64(double %x)
%c = select i1 %z, double 0x7fff000000000000, double %b
ret double %c
} But maybe we could ask the backend to recognize that sort of pattern. |
@jckarter Yeah, I would expect it not to. The backend knows how to lower an actual |
@stephentyrone Not without dirty tricks. @gribozavr Would it be possible for the stub implementation to be // Forward-declare sqrt to avoid including the real Darwin module.
double sqrt(double);
// Stub out a call to it.
static inline double _swift_stdlib_sqrt(double x) { return sqrt(x); } |
…though |
I'd rather not forward-declare |
@jckarter @gribozavr Worked around using |
SGTM. |
@swift-ci please test Linux. |
@jckarter @gribozavr @rjmccall Do you know what attributes we need on these static inlines to placate the linux build gods? |
@stephentyrone This looks like a compiler bug to me. |
@@ -84,35 +84,35 @@ __swift_uint32_t | |||
_swift_stdlib_cxx11_mt19937_uniform(__swift_uint32_t upper_bound); | |||
|
|||
// Math library functions | |||
SWIFT_RUNTIME_STDLIB_INLINE | |||
SWIFT_RUNTIME_STDLIB_INTERFACE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you should need any attributes at all on these functions.
Agree with @gribozavr, looks like SILGen's neglecting to emit something. |
Ok, I'll add a workaround for non-macOS once I have my current world-is-on-fire P1 dealt with. |
@swift-ci please test linux. |
This reverts commit 999885f. This breaks the stdlib serialization tests: Assertion failed: (!hasSharedVisibility(F->getLinkage()) && "external declaration of SILFunction with shared visibility is not " "allowed"), function visitSILFunction, file /s/sptr/swift/lib/SIL/SILVerifier.cpp, line 3267.
Please see https://ci.swift.org/job/oss-swift_tools-RA_stdlib-RDA_long-test/507/ Assertion failed: (!hasSharedVisibility(F->getLinkage()) && "external declaration of SILFunction with shared visibility is not " "allowed"), function visitSILFunction, file /s/sptr/swift/lib/SIL/SILVerifier.cpp, line 3267. While verifying SIL function @_swift_stdlib_sqrtf Sorry, I don't know enough about the shims to fix it on the spot. But apparently SIL verifier cannot handle these static inline functions ?? |
@atrick Why didn't we see this failure in the pre-submission test? |
Rather than reverting this, a much better fix would be to remove the |
Pre-submission test does not build the library in all modes, probably Release+DebugInfo+Assertions trips a bug in the compiler. |
My concern is that if the compiler choked on one, then it is likely that others will also break in a similar way. If not in our tests, then in users' code. |
@gribozavr I don't understand your comment. There are no "others" for it to choke on. Those are the only |
I meant that the compiler didn't like |
I don't think the presubmission tests run the "check-swift-long" does it? I was actually hitting this locally and it was blocking my work yesterday because I specifically needed to verify stdlib parsing. |
My suggestion is that we switch all six inlines to out-of-lines. That's what removing the |
@stephentyrone Sorry, I misunderstood you then! |
Reworked as #3530 without the static inlines. |
@stephentyrone Can you file a bug on the static inline problem referencing this PR? |
@atrick https://bugs.swift.org/browse/SR-2089. A bit vague since I don't actually understand the source of the error =) |
Resolve conflicts with the `main` branch
What's in this pull request?
Replace shims for
ceil
,floor
,round
, etc. withBuiltins
to eliminate a level of indirection.Resolved bug number: (SR-2045)
Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
Validation Testing
Lint Testing
Note: Only members of the Apple organization can trigger swift-ci.