Commit Graph

1572 Commits

Author SHA1 Message Date
Hamish Knight
56929fdaaa [TBDGen] Return a vector of symbols instead of set
A couple of clients are iterating over the result,
so switch to a vector to ensure we don't
accidentally introduce any non-determinism.
2020-07-15 17:48:51 -07:00
Hamish Knight
c0a2ea7d0e Sink linker directive computation into IRGen
With an inverted pipeline, IRGen needs to be able
to compute the linker directives itself, so sink
it down such that it can be computed by the
`IRGenDescriptor`.
2020-07-15 17:46:14 -07:00
Hamish Knight
c354b0faa1 [TBDGen] Return a vector of symbols instead of set
A couple of clients are iterating over the result,
so switch to a vector to ensure we don't
accidentally introduce any non-determinism.
2020-07-13 20:42:54 -07:00
Hamish Knight
db7fea4665 Sink linker directive computation into IRGen
With an inverted pipeline, IRGen needs to be able
to compute the linker directives itself, so sink
it down such that it can be computed by the
`IRGenDescriptor`.
2020-07-13 20:42:54 -07:00
Doug Gregor
f818a1e1b0 [Driver/IRGen] Put backward-deployment libraries into a table.
Describe the backward-deployment libraries via a preprocessor-driven
table. Macro-metaprogramming the two places in the code base---the
driver and IRGen---to use this tabble to determine which
backward-compatibility libraries to link against.
2020-07-07 23:11:37 -07:00
swift_jenkins
f496210e1a Merge remote-tracking branch 'origin/master' into master-next 2020-07-01 14:59:55 -07:00
Hamish Knight
fa715820a9 [IRGen] Assert the SourceFile has been type-checked 2020-07-01 09:43:51 -07:00
David Zarzycki
b7664fa320 [IRGen] Adjust to upstream LLVM change
GlobalValue::getAlignment() was removed in a2caa3b61497b6be8c8b77823d0fd62b4be1f177.
2020-06-24 14:42:33 -04:00
swift_jenkins
debe1f27c8 Merge remote-tracking branch 'origin/master' into master-next 2020-06-15 11:19:44 -07:00
Keith Smiley
76ca05f7b1 reland: Emit coverage mappings for all modules
This reverts commit 499ed05fd9.

This changes the num-threads passed to 1 to avoid a multithreaded output
issue on windows
2020-06-14 13:13:47 -07:00
swift_jenkins
0bc30e312e Merge remote-tracking branch 'origin/master' into master-next 2020-06-11 07:39:16 -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
swift_jenkins
136859e08f Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 20:19:05 -07:00
Saleem Abdulrasool
499ed05fd9 Revert "Emit coverage mappings for all modules" 2020-06-10 15:16:00 -07:00
swift_jenkins
e3bbcdc7df Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 12:39:02 -07:00
swift-ci
1fb06f1952 Merge pull request #32216 from keith/ks/coverage-modules 2020-06-10 12:34:28 -07:00
swift_jenkins
48530ac212 Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 10:39:00 -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
Arnold Schwaighofer
825a2a259b Mark non-foreign entry points of @objc dynamic methods in generic classes dynamically_replaceable
```
class Generic<T> {
  @objc dynamic func method() {}
}

extension Generic {
  @_dynamicReplacement(for:method())
  func replacement() {}
}
```

The standard mechanism of using Objective-C categories for dynamically
replacing @objc methods in generic classes does not work.

Instead we mark the native entry point as replaceable.

Because this affects all @objc methods in generic classes (whether there
is a replacement or not) by making the native entry point
`[dynamically_replaceable]` (regardless of optimization mode) we guard this by
the -enable-implicit-dynamic flag because we are late in the release cycle.

* Replace isNativeDynamic and isObjcDynamic by calls to shouldUse*Dispatch and
  shouldUse*Replacement
  This disambiguates between which dispatch method we should use at call
  sites and how these methods should  implement dynamic function
  replacement.

* Don't emit the method entry for @_dynamicReplacement(for:) of generic class
  methods
  There is not way to call this entry point since we can't generate an
  objective-c category for generic classes.

rdar://63679357
2020-06-09 09:23:29 -07:00
Karoy Lorentey
57ea964f2c Merge commit '3eb82c183662945687f48e11c09828f551b34858' into master-next
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:58:37 -07:00
Keith Smiley
8215ea105c Emit coverage mappings for all modules
Previously in WMO builds where IR was multithreaded only the
primary module would emit the coverage mapping leading to only the first
object file to have the __llvm_covmap section. This change emits
coverage for all modules so they are correctly reflected in the final
coverage report.
2020-06-08 16:35:35 -07:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
swift_jenkins
8b380c38b6 Merge remote-tracking branch 'origin/master' into master-next 2020-05-29 17:39:08 -07:00
Nate Chandler
bdef1cef23 [metadata prespecialization] Support for classes.
When generic metadata for a class is requested in the same module where
the class is defined, rather than a call to the generic metadata
accessor or to a variant of typeForMangledNode, a call to a new
accessor--a canonical specialized generic metadata accessor--is emitted.
The new function is defined schematically as follows:

    MetadataResponse `canonical specialized metadata accessor for C<K>`(MetadataRequest request) {
      (void)`canonical specialized metadata accessor for superclass(C<K>)`(::Complete)
      (void)`canonical specialized metadata accessor for generic_argument_class(C<K>, 1)`(::Complete)
      ...
      (void)`canonical specialized metadata accessor for generic_argument_class(C<K>, count)`(::Complete)
      auto *metadata = objc_opt_self(`canonical specialized metadata for C<K>`);
      return {metadata, MetadataState::Complete};
    }

where generic_argument_class(C<K>, N) denotes the Nth generic argument
which is both (1) itself a specialized generic type and is also (2) a
class.  These calls to the specialized metadata accessors for these
related types ensure that all generic class types are registered with
the Objective-C runtime.

To enable these new canonical specialized generic metadata accessors,
metadata for generic classes is prespecialized as needed. So are the
metaclasses and the corresponding rodata.

Previously, the lazy objc naming hook was registered during process
execution when the first generic class metadata was instantiated. Since
that instantiation may occur "before process launch" (i.e. if the
generic metadata is prespecialized), the lazy naming hook is now
installed at process launch.
2020-05-29 13:20:33 -07:00
Arnold Schwaighofer
2b2f7dcd2f Adjust to AllocaInst MaybeAlign -> Align api change 2020-05-20 07:45:43 -07:00
Anthony Latsis
55447e66aa Merge pull request #31645 from AnthonyLatsis/relocate-to-iterabledc
[NFC] AST: Relocate some conformance lookup client methods from DeclContext to IterableDeclContext
2020-05-18 22:25:08 +03:00
Arnold Schwaighofer
5d3f1739b9 IRGen: Only replace opaque result types of function result types when
performing a dynamic replacement

rdar://61936622
2020-05-15 12:12:55 -07:00
Anthony Latsis
bfe25fabeb [NFC] AST: Relocate getLocalConformances to IterableDeclContext 2020-05-08 17:43:09 +03:00
Slava Pestov
dd0ce1ad13 Remove the integrated REPL 2020-05-06 22:29:05 -04:00
Arnold Schwaighofer
d1bc9acea5 IRGen: Fix alignment of global variable buffer for non-fixed types
It needs to have the getFixedBufferAlignment because that is the value we use to determine whether the type
will be stored inline in the buffer or outline in an allocated buffer

rdar://62443743
2020-04-28 11:54:51 -07:00
Joe Groff
948372b87c Merge pull request #31087 from jckarter/compatibility-51
Start a Compatibility51 library for backporting fixes to Swift 5.1 runtimes
2020-04-17 15:06:50 -07:00
Joe Groff
42514f42e0 Start a Compatibility51 library for backporting fixes to Swift 5.1 runtimes 2020-04-17 10:41:48 -07:00
Robert Widmann
85fdc7a555 Merge pull request #31080 from CodaFi/why-I-R-ta
Give IRGenModule Ownership of its LLVMContext
2020-04-17 10:32:46 -07:00
Michael Forster
8d1d9f1eb5 Remove calls to deprecated IRBuilder APIs
These APIs have been removed in upstream LLVM, breaking master-next.
2020-04-17 09:32:03 +02:00
Robert Widmann
40d9cd8d3f [NFC] Give IRGenModule Exclusive Ownership of an LLVMContext Object 2020-04-16 11:57:44 -07:00
Dan Zheng
c834696bfa Add SynthesizedFileUnit.
`SynthesizedFileUnit` is a container for synthesized declarations. Currently, it
only supports module-level declarations.

It is used by the SIL differentiation transform, which generates implicit struct
and enum declarations.
2020-04-07 18:29:26 -07:00
Robert Widmann
a9e11e3130 [NFC] Separate Taking Redundant Conformance Diagnostics From The Lookup Table 2020-03-24 12:40:11 -07:00
Saleem Abdulrasool
29c00f6969 IRGen: improve DLLStorage computation for Windows
This slightly regresses the standard library build (intentionally) while
generally improving the build of dispatch, foundation, xctest.

Rather than continuing to rely on the short-term hack of special casing
the standard library, identify the module where the decl originates
from.  If the module is the current module, then assume that the symbol
need not be imported (static linking does not currently work on Windows
anyways).  This allows for properly identifying the module where the
symbol will be homed.

Because we no longer special case the standard library here, a few known
metadata types will be incorrectly marked as being imported rather than
local.

Since linked entities which have `Shared` SILLinkage should be module
local, special case them to always be local.  Without this the metadata
access function is still marked incorrectly.

With this computation we now get nearly all the cases correct.  Dispatch
no longer has to rely on the linker relaxing the import to a local
binding.  XCTest is also clean.  Foundation misses the following case:
- `$sSS10FoundationE19_bridgeToObjectiveCAA8NSStringCyF`

The regressed cases in swiftCore are:
- `$sBi64_WV`
- `$sBi8_WV`
- `$sBi16_WV`
- `$sBi32_WV`
- `$sBpWV`
- `$syycWV`
- `$sBoWV`
- `$sBOWV`
- `$sBbWV`
- `$sytWV`
2020-03-08 19:24:29 -07:00
Kuba Mracek
8a4a226cd6 Undo unintentional llvm::MaybeAlign changes 2020-03-07 13:44:16 -08:00
Kuba (Brecka) Mracek
5d918e5ee1 Merge branch 'master' into mracek/arm64e 2020-03-03 08:28:01 -08:00
Robert Widmann
de72824b04 [Gardening] Canonicalize usages of ASTContext::Stats 2020-02-27 17:12:58 -08:00
Kuba Mracek
84c4864911 [arm64e] Add Swift compiler support for arm64e pointer authentication 2020-02-27 16:10:31 -08:00
Arnold Schwaighofer
335be17562 IRGen: Reinstate JIT workaround removed in PR #28704
The usage of private vars that seemingly are accessed accross object
files confuses the JIT.

rdar://59782487
2020-02-26 08:00:05 -08:00
Dan Zheng
1779632a6f [IRGen] NFC: silence llvm::MaybeAlign warnings.
Use `llvm::MaybeAlign` instead of `unsigned` to silence slew of warnings.
2020-02-20 08:49:28 +00:00
Slava Pestov
836a0b9722 IRGen: Remove IRGenModule::CurSourceFile 2020-02-11 18:59:21 -05:00
Slava Pestov
e6dc10accd IRGen: More accurate getAddrOfLLVMVariableOrGOTEquivalent()
The logic here used to consist of a couple of ad-hoc checks,
followed by a general assumption that if something had already
been emitted, it could be referenced directly, whereas everything
else had to go through a GOT entry.

This is way too conservative. Instead, let's try to correctly
calculate what translation unit an entity is going to end up in.
2020-02-11 18:59:21 -05:00
Slava Pestov
8bdabe81ad IRGen: Add LinkEntity::getDeclContextForEmission()
This replaces getSourceFileForEmission().
2020-02-11 18:59:21 -05:00
Slava Pestov
7fb62337a6 IRGen: Remove old workaround to force emitting GOT entries
The logic in getAddrOfLLVMVariableOrGOTEquivalent() should be
sufficient to decide if a GOT entry is needed.
2020-02-11 18:59:21 -05:00
Slava Pestov
762ab4fc6a IRGen: Add a counter for GOT entries emitted 2020-02-11 18:59:21 -05:00
swift-ci
fda8e977e1 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-07 14:24:32 -08:00