Commit Graph

4196 Commits

Author SHA1 Message Date
Saleem Abdulrasool
8e86d0fbbd IRGen: always execute the coroutine lowering pass
Do not gate the coroutine extension points on the LLVM passes. Without
running this pass, the generated IR cannot be used by the LLVM tooling.
This allows generating the LLVM IR to debug issues in the LLVM backend.

I encountered this when trying to isolate a debug info generation bug
which seems to be caused by the SRoA pass in LLVM. By allowing to emit
the LLVM IR without the LLVM optimizations, it is possible to isolate
the LLVM pass operation via `opt` from LLVM.
2020-07-27 23:17:30 +00:00
Joe Groff
90f0f7c627 Merge pull request #32359 from jckarter/enable-prune-vtables
Add PruneVTables to the performance optimizer passes.
2020-07-27 11:10:53 -07:00
Meghana Gupta
c042638a37 Merge pull request #33098 from meg-gupta/updatestyle
Update code as per Apple Style Guide
2020-07-25 07:44:44 -07:00
Joe Groff
2dac5846ee IRGen: Keep vtables entries inherited from fragile base classes.
If a subclass is resilient, but has a fragile base class, we need to preserve the ABI-exposed vtable entries
inherited from the base class.
2020-07-24 14:16:23 -07:00
Meghana Gupta
b34791a0a0 Update code as per Apple Style Guide
whitelist -> allowlist
blacklist -> denylist
2020-07-24 11:37:15 -07:00
Joe Groff
3a9440a379 IRGen: Elide nonoverridden entries from public resilient vtables.
A formally virtual method still needs to provide the ABI of an overridable
method, including a dispatch thunk, method descriptor, and support in the
method lookup function for the class to handle `super.` calls from clients.
2020-07-23 20:40:49 -07:00
Joe Groff
b4a0ceac71 Add PruneVTables to the performance optimizer passes. 2020-07-23 20:40:49 -07:00
Nate Chandler
52d33973fa [Test] Disabled struct-outmodule-run on remote_run.
rdar://problem/65999266
2020-07-23 17:23:53 -07:00
swift-ci
4130d5c126 Merge pull request #33048 from nate-chandler/rdar65935026 2020-07-22 13:35:36 -07:00
Nate Chandler
d4a5a9971e [Test] Eased prespecialization FileCheck tests.
rdar://problem/65935026
2020-07-22 10:43:08 -07:00
Arnold Schwaighofer
5a1f061de8 Merge pull request #33029 from aschwaighofer/fix_autolink_test_macos
autolink-runtime-compatibility.swift requires x86_64
2020-07-22 07:30:37 -07:00
Slava Pestov
e6e9b6e352 Merge pull request #32887 from slavapestov/fixed-layout-protocols
AST: Allow @_fixed_layout protocols
2020-07-21 13:46:36 -04:00
Arnold Schwaighofer
208a9453d5 autolink-runtime-compatibility.swift requires x86_64
The arm64 variation is tested in autolink-runtime-compatibility-arm64-macos.swift

rdar://65245133
2020-07-21 09:03:22 -07:00
Slava Pestov
4a47190335 AST: Allow @_fixed_layout protocols
A @_fixed_layout protocol exposes its witness table layout to
clients, which prevents re-ordering of requirements or adding
new requiremenst with a default.

When library evolution is enabled, we still emit method
descriptors even for @_fixed_layout protocols; this allows a
previously-resilient protocol to become @_fixed_layout as long
as the published layout matches the resilient layout in all
previously-shipped versions of the library.
2020-07-20 23:53:41 -04:00
Nate Chandler
d4b82bacca [metadata prespecialization] Cross-module: enums and structs.
When a generic type from a different module is not resilient within the
current module and at least one of its arguments is from the current
module, emit a non-canonical prespecialized record, and access that
metadata via a call to swift_getCanonicalSpecializedMetadata, passing in
the non-canonical record.

rdar://problem/56996727
rdar://problem/56997022
2020-07-16 14:14:01 -07:00
Joe Groff
f807297f25 Merge pull request #32861 from jckarter/name-private-conformance-descriptor-cache
IRGen: Name the symbol for the private use area attached to protocol conformance descriptors.
2020-07-14 12:46:48 -07:00
Joe Groff
7d3a4b1c0c IRGen: Name the symbol for the private use area attached to protocol conformance descriptors.
Make it easier to track the memory usage of these symbols.
2020-07-14 10:02:43 -07:00
Nate Chandler
9a94dec1e2 [metadata prespecialization] Reflect ptrauth in tests.
Now that conformance descriptors are signed before being passed to
swift_compareProtocolConformanceDescriptors on arm64e from metadata
accessors when prespecialization is enabled, the tests must be updated
for that platform to look for the signing.
2020-07-10 07:42:01 -07:00
Saleem Abdulrasool
1782cf0386 test: repair windows builder after #32429
The test was overly strict in checking the IR, loosen the test
appropriately.
2020-07-07 22:27:57 +00:00
Michael Gottesman
5fa68c5ec3 Merge pull request #32429 from kateinoigakukun/katei/llvm-lto-driver-part
[LTO] Support LLVM LTO for IRGen and frontend
2020-07-07 12:09:28 -07:00
Varun Gandhi
e1094f72b5 [NFC] Remove stray E in lit.py variable binding. (#32713) 2020-07-07 11:11:25 -07:00
Mishal Shah
10dda582d6 [Apple Silicon] Update tests for no macOS target triple canonicalization
LLVM no longer canonicalizes target triples for maOS versions. Update
tests to account for this.
2020-07-02 19:30:01 -07:00
Mishal Shah
60d996f060 [Apple Silicon] Add support for triple and availability canonicalization 2020-07-02 19:26:25 -07:00
Mishal Shah
3c9e72f6e1 [Apple Silicon] [macCatalyst] Baseline arm64(e) macCatalyst at Swift 5.3/iOS 14.0. 2020-07-02 18:28:33 -07:00
Mishal Shah
0c2617f47a [Apple Silicon] [IRGen] Fix test for arm64 macOS 2020-07-02 18:26:42 -07:00
Mishal Shah
efe5907e0b [Apple Silicon] [Test] Fix various IRGen tests for arm64 macOS 2020-07-02 17:56:54 -07:00
Mishal Shah
134f202e01 [Apple Silicon] Baseline arm64 macOS at Swift 5.3 / macOS 10.16 2020-07-02 16:42:15 -07:00
Mishal Shah
4c97d0cbe5 [Apple Silicon] [ObjectiveC Overlay] ObjCBool is C _Bool on arm64 macOS. 2020-07-02 16:41:01 -07:00
Mishal Shah
92ca9fc924 [Apple Silicon] Generalize tests for other macOS architectures
Most of the changes fall into a few categories:
* Replace explicit "x86_64" with %target-cpu in lit tests
* Cope with architecture differences in IR/asm/etc. macOS-specific tests
2020-07-02 16:27:46 -07:00
Alex Lorenz
f1bba3e1bf Disable a RUN line in osx-targets.swift
Darwin 55 is now translated to macOS 46 after the LLVM changes landed that added support for macOS 11. This change temporarily disables the RUN line in the test that uses the `darwin55` triple until the appropriate fix is upstreamed on the swift side.
2020-07-02 08:47:55 -07:00
Yuta Saito
20bc0af42b [LTO] Support LLVM LTO for IRGen and frontend
This commit adds -lto flag for frontend to enable LTO at LLVM level.
When -lto=llvm given, compiler emits LLVM bitcode file instead of object
file and adds index summary for LTO.
In addition for ELF format, emit llvm.dependent-libraries section to
embed auto linking information
2020-07-01 23:30:58 +00:00
Robert Widmann
50159d15b7 [Gardening] Use Vendor=apple Where Possible
This simplifies the usual bundle of OS checks

OS=macosx || OS=ios || OS=tvos || OS=watchos

into

VENDOR=apple

which was added in apple/swift#27307
2020-06-30 23:03:01 -07:00
Robert Widmann
cddf73ecdb [Gardening] Clean Up OS-Test Patterns Across The Codebase
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.
2020-06-30 22:55:58 -07:00
Nate Chandler
beb75a18b4 [Test] Disabled remote_run on prespecialized-metadata/struct-multi-conformance.swift. 2020-06-24 15:22:13 -07:00
nate-chandler
de8107ebef Merge pull request #32482 from nate-chandler/generic-metadata-prespecialization-components/consider-conformances
[metadata prespecialization] Check conformances.
2020-06-24 09:46:34 -07:00
Nate Chandler
a5f0069b8d [metadata prespecialization] Check conformances.
Previously, the metadata accessor for a generic type for which some
metadata prespecialization was done only tested that the type metadata
arguments were equal to those of the prespecialization.  If the generic
type had an argument which was constrained to conform to a protocol, the
particular conformance to that protocol was determined at compile time,
but the conformance was ignored in the metadata accessor.  As a result
it was possible--in certain multi-module cases--for the metadata
accessor to incorrectly return a prespecialized metadata record whose
type arguments matched the type arguments passed to the accessor but
whose conformance arguments did not.

For example, given the following,

  Base:
    struct K {}
    protocol P {}

  Conformance1:
    import Base
    struct G<T : P> {}
    extension K : P {} // first conformance
    prespecialize( G<K>.self )

  Conformance2:
    import Base
    extension K : P {} // second conformance

the metadata accessor for G defined in Conformance1 would behave like

  MetadataResponse `metadata accessor for G`(
      MetadataRequest request,
      const Metadata *M,
      const WitnessTable *WT) {
    if (M == `type metadata for K`) {
      return `canonical prespecialized type metadata for G<K>`
    }
    return swift_getGenericMetadata(request, {M, WT});
  }

Here, the WitnessTable argument is the witness table describing a
conformance of the type whose metadata is provided to the protocol P.

The incorrect behavior occurs when calling the metadata accessor with
these arguments:

    `some request`
    `type metadata for K`
    `protocol witness table for Base.K : Base.P in Conformance2`

The accessor would return the `canonical prespecialized type metadata
for G<K>`.  The problem is that the prespecialized metadata contains the
following generic arguments:

    `type metadata for K`
    `protocol witness table for Base.K : Base.P in Conformance1`

Specificallly, the witness table is for the conformance from
Conformance1, not the conformance from Conformance2.

Here, the problem is addressed by testing that the witness tables passed
into the accessor are for the same conformance as the witness table
referred to by the prespecialized record.  Now, the metadata accessor
for G will behave like

  MetadataResponse `metadata accessor for G`(
      MetadataRequest request,
      const Metadata *M,
      const WitnessTable *WT) {
    if (M == `type metadata for K`
        swift_compareProtocolConformanceDescriptors(
          WT->getDescription(),
          `protocol conformance descriptor for Base.K : Base.P in Conformance1`)
       ) {
      return `canonical prespecialized type metadata for G<K>`
    }
    return swift_getGenericMetadata(request, {M, WT});
  }

Consequently, when the accessor is called with the same arguments as
before, the call to swift_compareProtocolConformanceDescriptors will
return false and the non-matching prespecialized metadata will not be
returned.
2020-06-22 20:34:23 -07:00
Mishal Shah
272c466e47 Update master to build with Xcode 12 beta 2020-06-22 15:43:20 -07:00
Michael Gottesman
702c1bc5e8 [arc] Change guaranteed arc opts to be based on SemanticARCOpts and move from Diagnostic pipeline -> Onone pipeline.
The pass is already not being run during normal compilation scenarios today
since it bails on OSSA except in certain bit-rot situations where a test wasn't
updated and so was inadvertently invoking the pass. I discovered these while
originally just trying to eliminate the pass from the diagnostic pipeline. The
reason why I am doing this in one larger change is that I found there were a
bunch of sil tests inadvertently relying on guaranteed arc opts to eliminate
copy traffic. So, if I just removed this and did this in two steps, I would
basically be unoptimizing then re-optimizing the tests.

Some notes:

1. The new guaranteed arc opts is based off of SemanticARCOpts and runs only on
   ossa. Specifically, in this new pass, we just perform simple
   canonicalizations that do not involve any significant analysis. Some
   examples: a copy_value all of whose uses are destroys. This will do what the
   original pass did and more without more compile time. I did a conservative
   first approximation, but we can probably tune this a bit.

2. the reason why I am doing this now is that I was trying to eliminate the
   enable-ownership-stripping-after-serialization flag and discovered that the
   test opaque_value_mandatory implicitly depends on this since sil-opt by
   default was the only place left in the compiler with that option set to false
   by default. So I am eliminating that dependency before I land the larger
   change.
2020-06-15 17:00:18 -07:00
Arnold Schwaighofer
4849947919 Merge pull request #32277 from aschwaighofer/irgen_fix_addAbstractConditionalRequirements
IRGen: Lookup the conformance of an archetype in the right substitution map when computing necessary bindings of abstract cnditional requirements
2020-06-15 10:54:13 -07:00
Joe Groff
04c8f0df42 IRGen: Don't reify internal vtable entries that are marked overridden.
Private and internal classes shouldn't have ABI constraints on their concrete vtable layout, so if methods
don't have overrides in practice, we can elide their vtable entries.
2020-06-12 11:59:24 -07:00
Arnold Schwaighofer
8a2bfb046b No need to lookup the conformance we can just take the protocol from the requirement 2020-06-11 08:19:59 -07:00
Arnold Schwaighofer
abfbbbeee5 Merge pull request #32213 from aschwaighofer/note_use_of_type_metadata_in_conditional_reqts
IRGen: Note use of types in conditional requirements of protocol conformances
2020-06-11 07:27:30 -07:00
Robert Widmann
42d2f9d35d Merge pull request #32308 from 3405691582/Test_OpenBSD_XfailAndRequired
[test] Mark XFAIL tests for OpenBSD.
2020-06-11 00:36:52 -07:00
3405691582
7b431b4ddb [test] Mark XFAIL tests for OpenBSD.
These tests are marked XFAIL or UNSUPPORTED because either the tests:
require libc annotation, require Mach-O support, don't recognize calls to
swift-autolink-extract, requires porting alongside Linux, or rely on simd
which is not present.

Additionally, explicit REQUIRES for tsan/asan/fuzzer are added to some
tests, since OpenBSD does not support these sanitizers or fuzzers, since
it's nicer to mark that with REQUIRES rather than XFAIL.
2020-06-10 18:57:19 -04:00
Arnold Schwaighofer
05ed0dd1a6 Add back test case 2020-06-10 08:39:10 -07:00
Arnold Schwaighofer
65a08466fd Fix c_globals.swift test on arm64
This test sets -mno-omit-leaf-frame-pointer
2020-06-10 06:45:23 -07:00
Arnold Schwaighofer
2b47815973 IRGen: Lookup the conformance of an archetype in the right substitution map when computing necessary bindings of abstract cnditional requirements
SR-12853
2020-06-09 13:19:52 -07:00
Arnold Schwaighofer
7997183dbc IRGen: Move emitProtocolConformance before emitLazyDefinitions
It is possible that the only mention of metadata happens as part of protocol conformannce emission.
This ordering makes sure we emit this metadata.

SR-12891
rdar://63819461
2020-06-09 12:44:19 -07:00
nate-chandler
7c5a5e5041 Merge pull request #32174 from nate-chandler/generic-metadata-prespecialization-components/classes-nongeneric-superclasses
[metadata prespecialization] Support classes with non-generic ancestors.
2020-06-09 09:25:21 -07:00
Nate Chandler
8ec75d4933 [metadata prespecialization] Support classes with non-generic ancestors.
Previously, metadata prespecialization for classes only occurred when
all of a specialized generic class's ancestors were themselves generic.
Here, that requirement is lifted so that generic classes with concrete
ancestors are also eligible for prespecialization.
2020-06-08 14:57:50 -07:00