Without `_blackHole`, the optimizer may remove or make assumptions about values, which are not intended by the test.
This fixes the tests when running them in optimize mode and when OSSA modules are enabled.
This is part of rdar://140229560.
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.
arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
On Linux with -O:
[ RUN ] Set.formSymmetricDifference
stdout>>> check failed at /Users/docker_user/src/build/buildbot_linux/swift-linux-x86_64/main.swift, line 3245
stdout>>> unexpected value: "94788628116752" (of type Swift.Int)
[ FAIL ] Set.formSymmetricDifference
The test is roughly:
var s1 = Set(...)
let s1_copy = s1
let identity1 = s1._rawIdentifier()
s1.someMutatingMethod1()
check(s1)
check(s1_copy)
s1.someMutatingMethod2()
// Mutating the set should cause an identity change
releaseAssert(identity1 != s1._rawIdentifier())
On Linux, the optimizer is able to destroy s1_copy before the call to
s1.someMutatingMethod2(), which generates new Set storage. This new
storage uses the same address as the destroyed s1_copy.
Fixes rdar://72933150 ([CanonicalOSSA] Fix Set.swift unit test that assumes object lifetime)
The embedded shell script in the RUN command for lit is problematic for
non-sh shell environments (i.e. Windows). This adjusts the tests to
uniformly build the code for the ObjC runtime. However, the Objective-C
code is only built under the same circumstances that it is currently
enabled - the availability of the needed frameworks. The empty object
on other runtimes will have no material impact. The swift side of it
checks whether the runtime is built with ObjC interop. This allows us
to largely use the same command line for all the targets. The last
missing piece is that the `-fobjc-runtime` requires that we run a modern
ObjC runtime. We enable this unconditionally in lit for the non-Apple
targets.
This improves the validation test coverage for the standard library on
Windows.
Until the issue is fixed. Tracked by:
<rdar://problem/49791522> Swift CI Test failures: IRGen/autorelease_optimized_armv7/aarch64.
https://bugs.swift.org/browse/SR-10474
Along with updating tests to adopt the new storage class names, the behavior of removeAll() has changed slightly.
If t stored an empty Set/Dictionary that was bridged from Objective-C, t.removeAlI() used to keep the original Objective-C storage intact. Now removeAll() replaces the old storage with the empty singleton, which makes a lot more sense to me.
SwiftPrivate/PRNG.swift:
- currently uses `theGlobalMT19937`;
- previously used `arc4random` (see #1939);
- is obsoleted by SE-0202: Random Unification.
When Set/Dictionary is nested in another Set, the boundaries of the nested collections weren’t correctly delineated in commutative hashing.
For example, these Sets all hashed the same:
[[1, 2], [3, 4]]
[[1, 3], [2, 4]]
[[1, 4], [2, 3]]
Hash collisions could thus be systematically generated.
To fix this, remove collection-level support for one-shot hashing and revert to the previous method of generating hash values. (Set is still able to support one-shot hashing for its members, though.)
NSString has a stricter concept of equality than Swift’s String, so it is possible to construct NSDictionary/NSSet instances that contain duplicate keys according to Swift’s definition of string equality. This change improves how we handle these cases by coalescing the duplicate keys (keeping a single value).
rdar://problem/35995647
* Eradicate IndexDistance associated type, replacing with Int everywhere
* Consistently use Int for ExistentialCollection’s IndexDistance type.
* Fix test for IndexDistance removal
* Remove a handful of no-longer-needed explicit types
* Add compatibility shims for non-Int index distances
* Test compatibility shim
* Move IndexDistance typealias into the Collection protocol
Using && here causes us to go down a SILGen path that guarantees that self will
be evaluated over the entire && expression instead of just the LHS. This cause
the uniqueness check to always return false at -Onone. At -O, the optimizer is
smart enough to remove this issue.
rdar://33358110