This change adds support for WASI in stdlib tests. Some tests that expect a crash to happen had to be disabled, since there's currently no way to observe such crash from a WASI host.
This replaces swiftMSVCRT with swiftCRT. The big difference here is
that the `visualc` module is no longer imported nor exported. The
`visualc` module remains in use for a singular test wrt availability,
but this should effectively remove the need for the `visualc` module.
The difference between the MSVCRT and ucrt module was not well
understood by most. MSVCRT provided ucrt AND visualc, combining pieces
of the old MSVCRT and the newer ucrt. The ucrt module is what you
really wanted most of the time, however, would need to use MSVCRT for
the convenience aliases for type-generic math and the deprecated math
constants.
Unfortunately, we cannot shadow the `ucrt` module and create a Swift SDK
overlay for ucrt as that seems to result in circular dependencies when
processing the `_Concurrency` module.
Although this makes using the C library easier for most people, it has a
more important subtle change: it cleaves the dependency on visualc.
This means that this enables use of Swift without Visual Studio for the
singular purpose of providing 3 header files. Additionally, it removes
the need for the installation of 2 of the 4 support files. This greatly
simplifies the deployment process on Windows.
Clean up a few general patterns that are now obviated by canImport
This aligns more generally with the cleanup that the Swift Package
Manager has already done in their automated XCTest-plumbing tool in
apple/swift-package-manager#1826.
This commit focuses the basics: setting up the relevant stanzas in
lit.cfg and adding platform conditionals for importing Glibc. Future
commits will deal with other portability fixes.
* Revert "Add availability information to the new Math function protocols (#24187)"
This reverts commit d2f695935f.
* Revert "SE-0246: Protocols and static functions (#23824)"
This reverts commit 57a4553832.
* Expected abi changes.
This implements the protocols and static functions proposed in SE-0246, plus some initial test coverage. It also has some rough accompanying cleanup of tgmath. It does not include the globals (on scalars or SIMD types) nor does it deprecate much in tgmath.h.
* Revert "Merge pull request #23791 from compnerd/you-know-nothing-clang"
This reverts commit 5150981150, reversing
changes made to 8fc305c03e.
* Revert "Merge pull request #23780 from compnerd/math-is-terrible"
This reverts commit 2d7fedd25f, reversing
changes made to 0205150b8f.
* Revert "Merge pull request #23140 from stephentyrone/mafs"
This reverts commit 777750dc51, reversing
changes made to 0c8920e747.
This commit implements SE-0246, by adding conformance to Real to the Float, CGFloat, Double, and Float80 types, implemented either in terms of the system's C math library, existing standard library functionality, or LLVM intrinsics. It includes basic test coverage for these new functions, and deprecates and obsoletes *some* existing functionality in the Platform overlay. We still need to make a decision about how to handle the remaining "tgmath" functions, because obsoleting them is technically a source-breaking change (if users have unqualified names like "exp(1)", it's fine, but it would break users who have used qualified names like "Darwin.exp(1)".)
Different tests used different os checks for importing Darwin, Glibc and
MSVCRT. This commit use the same pattern for importing those libraries,
in order to avoid the #else branches of the incorrect patterns to be
applied to the wrong platform. This was very normal for Android, which
normally should follow the Linux branches, but sometimes was trying to
import Darwin or not importing anything.
The standarized pattern imports Darwin for macOS, iOS, tvOS and watchOS.
It imports Glibc for Linux, FreeBSD, PS4, Android, Cygwin and Haiku; and
imports MSVCRT for Windows. If a new platform is introduced, the else
branch will report an error, so the new platform can be added to one of
the branches (or maybe add a new specific branch).
In some cases the standard pattern was modified because some test required
it (importing extra modules, or extra type aliases), and in some other
cases some branches were removed because the test will not have used
them (but it is not exhaustive, so there might be some unnecessary
branches).
This should, at least, fix three tests for Android (the three
dynamic_replacement*.swift ones).
Avoid a temporary file and executing FileCheck multiple types and prefer
multiple check prefixes and streaming. Additionally, enable some of
previously XFAIL'ed tests on Linux as well as tests that were marked as
requiring Objective-C interop.
Un-XFAIL tests on Linux now that ObjC interop is controllable. There
are a couple of tests that remain which are dependent on Foundation.
Fix a configuration issue that resulted in a number of tests failing on
Linux.
This adds the dllstorage annotations on the tests. This first pass gets
most of the IRGen tests passing on Windows (though has dependencies on
other changes). However, this allows for the changes to be merged more
easily as we cannot regress other platforms here.
This test used to check that sqrt() did not use the LLVM intrinsic because
its behavior did not match IEEE 754 for negative inputs. That has now
changed in recent versions of LLVM. There are still some differences in
how the LLVM intrinsic handles errno, but that should not affect Swift.
With Clang r319593, the test began to fail because __builtin_sqrtf gets
translated to the LLVM intrinsic. Change the test to match.
* Mark libc math shims with always_inline attribute
We want these to always be inlined, so mark them with ... always_inline.
The compiler happened to do the right thing with them previously, but we
shouldn't depend on that.
<rdar://problem/30043258> master-next: IRGen/builtin_math.swift failing because sqrt(4) is not constant folded
Tracking the problem in rdar://problem/30043258. This check fails:
// CHECK-LABEL: define {{.*}}test5
// CHECK: ret float 2
public func test5( ) -> Float {
return sqrt(4)
}
The IR that we’re generating is:
define float @_TF12builtin_math5test5FT_Sf() #4 {
entry:
%0 = tail call fastcc float @_swift_stdlib_squareRootf(float 4.000000e+00)
ret float %0
}
Note that the Double version in test6 works as expected.
* Go back to using static inline implementations of sqrt and remainder now that SR-2089 is resolved.
* Fix typo: sqrt -> squareRoot.
* Added test for constant-folding sqrt with -O.
* Added test case requested by jrose.
* Use intrinsics instead of Libc stubs where we can.
This replaces most of the stubs used for basic operations on these
types with intrinsics, eliminating a level of indirection for fma,
ceil, floor, round, trunc.
square root and remainder still require stubs because there is no
remainder intrinsic and we can't use the square root intrinsic because
its behavior is undefined for negative inputs. A previous commit
apparently either the compiler annotates static inline stubs wrong
or the SIL verifier can't handle them, so that change was backed out.
* Explicitly CHECK-NOT @llvm.sqrt instead of looking for @sqrt.
This reapplies commit r22864 - it is not changing the public api as we initially
thought. sqrt() was never available without importing Darwin.
This change only changes where sqrt() gets "forwarded" to. Before 'sqrt' called
the builtin '_sqrt' defined in BuiltinMath now it just calls the math library's
'sqrt' function.
I also added a stdlib test.
rdar://18371371
Swift SVN r22870
This is controlled by a new isWholeModule() attribute in SILModule.
It gives about 9% code size reduction on the benchmark executables.
For test-suite reasons it is currently not done for the stdlib.
Swift SVN r22491