Commit Graph

629 Commits

Author SHA1 Message Date
Anthony Latsis
2843e0c871 Gardening: Migrate compiler sources to GitHub issues 2022-09-29 23:58:55 +03:00
Arnold Schwaighofer
101cf45324 Merge pull request #61204 from aschwaighofer/sign_function_pointer_for_enum_tag_runtime_calls
IRGen: Sign function pointers passed to swift_(store/get)EnumTagSinglePayloadGeneric calls
2022-09-20 12:54:25 -07:00
Arnold Schwaighofer
7d283332e5 IRGen: Sign function pointers passed to swift_(store/get)EnumTagSinglePayloadGeneric calls
rdar://100129824
2022-09-20 08:32:06 -07:00
Hamish Knight
01c7c16c18 [IRGen] Allow lazy emission of coverage mapped functions
We previously eagerly emitted such functions to
ensure that their name data is emitted through the
profiler increment. Now that are able to emit the
profile name data separately, this is unnecessary,
and we can avoid emitting their definitions.
2022-09-16 15:47:17 +01:00
Arnold Schwaighofer
9bbf74ecb2 Run instruction profiling pass at the start of the pipeline
rdar://77217762
2022-09-12 10:07:23 +01:00
Arnold Schwaighofer
a0ef942e19 IRGen: Use the clang type descriminator for TaskContinuationFunction*
rdar://98992498
2022-08-24 10:52:13 -07:00
swift-ci
bd109664fb Merge remote-tracking branch 'origin/main' into rebranch 2022-08-11 10:54:47 -07:00
swift-ci
9c4972ff84 Merge pull request #42366 from kateinoigakukun/katei/fix-hermetic-seal-with-lld
[IRGen] Emit mod summary for full LTO to enable hermetic seal with lld
2022-08-11 10:48:48 -07:00
Ben Barham
183993c2da [rebranch] Use new AddressSanitizerOptions in pass construction
llvm/llvm-project `3131714f8daca338492a7d5b189e4d63131bc808` changed
`ModuleAddressSanitizerPass` to take an `AddressSanitizerOptions`
instead. `b7fd30eac3183993806cc218b6deb39eb625c083` also removed
`AddressSanitizerPass` after it was rolled into
`ModuleAddressSanitizerPass` in
`b7fd30eac3183993806cc218b6deb39eb625c083`.

Update IRGen to use the new options and remove the additional pass.
2022-07-19 13:18:07 -07:00
swift-ci
c84de33192 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-19 07:33:14 -07:00
Arnold Schwaighofer
3dac6c9f90 IRGen: Introduce the option to use the new llvm pass manager 2022-07-15 13:11:31 -07:00
Arnold Schwaighofer
5c9eab0f6c Update Swift's LLVM passes to include new pass manager versions 2022-07-15 08:22:32 -07:00
Arnold Schwaighofer
5c4c12a35d IRGen: Switch pass managers based on LegacyPassManager IRGenOptions flag 2022-07-13 08:19:54 -07:00
swift-ci
1ec185309f Merge remote-tracking branch 'origin/main' into rebranch 2022-06-24 00:14:42 -07:00
Erik Eckstein
ca291fb147 SIL: store IRGenOptions in SILModule
SIL optimization passes can use the IRGen options to do target specific optimizations.
2022-06-23 22:16:42 +02:00
swift-ci
6edca9f86e Merge remote-tracking branch 'origin/main' into rebranch 2022-06-13 15:13:15 -07:00
Robert Widmann
a845fa5683 Merge pull request #59383 from CodaFi/file-this-one-under-i-for-immutable
Don't Mutate ModuleDecl's File List When Creating Synthesized Files
2022-06-13 16:03:41 -06:00
Robert Widmann
ac6836053d [NFC] Use an Iterator Again in WMO Type Checking 2022-06-13 11:09:24 -06:00
Robert Widmann
0d117c1345 Don't Mutate ModuleDecl's File List When Creating Synthesized Files
See #59144 for more on why this is a bad idea.

Patch out the synthesized file unit accessor to only clear the source cache, then patch up all the places that were assuming they could iterate over the module's file list and see synthesized files.

rdar://94164512
2022-06-11 11:07:05 -06:00
swift-ci
7cb90dc351 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-10 15:33:41 -07:00
Arnold Schwaighofer
821ba47079 IRGen: Add a frontend option to force single LLVM module emission in multithreaded mode
This allows to experiment with single module LLVM emission without
having to change drivers that expect multiple output files.

rdar://94744623
2022-06-10 09:46:07 -07:00
Ben Barham
b521dc7c42 [next] Handle new ObjectFormatTypes
LLVM has added two new object format types, add them as unhandled for
now.
2022-05-05 16:25:10 -07:00
Erik Eckstein
45acb912a9 Revert "Add a mechanism to let cross-module-optimization add additional TBD symbols."
This reverts commit c55f040308.

It's not needed anymore because CMO does not introduce public symbols when a TBD file is emitted.
2022-04-29 18:22:55 +02:00
Arnold Schwaighofer
609428cad9 IRGen: disable-llvm-optzns should disable the objc-arc-contract pass
Don't run the objc-arc-contract pass when disable-llvm-optzns is passed.

In pipeline setups where the swift-frontend is called twice;
- the first time to create bitcode
- the second time to generate object code from the bitcode (using
  disable-llvm-optzns)
we don't want to run the objc-arc-contract pass twice.

rdar://91908312
2022-04-18 13:47:10 -07:00
Yuta Saito
620609076d [IRGen] Emit mod summary for full LTO to enable hermetic seal with lld
LTO pipeline requires consistent `EnableSplitLTOUnit` and module summary
in regular full LTO bitcode, and clang enables `EnableSplitLTOUnit` and
emit regular lto module summary on non-ld64 platforms.
Therefore, swiftc has to emit them for the consistency with clang.
2022-04-14 15:53:46 +00:00
John McCall
6385934d7e Metadata emission for extended existential type shapes 2022-04-12 14:52:47 -04:00
Michael Gottesman
a553b874ce [move-function] Rather than breaking block at the SIL level after moved dbg_value, do it late as an LLVM pass on llvm.dbg.addr
This has a few nice benefits:

1. The splitting happens after LLVM optimizations have run. This ensures that
LLVM will not join these blocks no matter what! The author of this commit has
found that in certain cases LLVM does this even at -Onone. By running this late,
we get the benefit we are looking for: working around the bad SelectionDAG
behavior.

2. This block splitting is just a workaround for the above mentioned unfortunate
SelectionDAG behavior. By doing this when we remove the workaround, we will not
have to update SIL level tests... instead we will just remove a small LLVM pass.

Some additional notes:

1. Only moved values will ever have llvm.dbg.addr emitted today, so we do not
have to worry about this impacting the rest of the language.

2. The pass's behavior is tested at the IR level by move_function_dbginfo.swift.
2022-03-07 19:55:21 -08:00
Michael Gottesman
6dde338a11 [sil-opt] Actually pass down IRGenOptions to irgen::createIRGenModule().
Otherwise the options from our invocation that we specialized in sil-opt's main
function will not take effect.
2022-02-18 12:56:36 -08:00
Erik Eckstein
fb8ee0edff extract the MD5Stream utility from IRGen to its own header file. 2022-02-01 08:13:27 +01:00
swift-ci
a7f9d15c2e Merge remote-tracking branch 'origin/main' into rebranch 2021-12-20 06:35:32 -08:00
Erik Eckstein
c55f040308 Add a mechanism to let cross-module-optimization add additional TBD symbols.
PublicCMOSymbols stores symbols which are made public by cross-module-optimizations.
Those symbols are primarily stored in SILModule and eventually used by TBD generation and validation.
2021-12-20 11:33:02 +01:00
swift-ci
134e17c8ec Merge remote-tracking branch 'origin/main' into rebranch 2021-12-17 16:54:09 -08:00
Pavel Yaskevich
a83101787d [IRGen] Implement accessible function section/record emission
Uses a dedicated section in the binary to emit records about
functions that can be looked up by name at the runtime, and
then called through a fully-abstracted entry point whose
arguments can be constructed in code.
2021-12-17 10:52:56 -08:00
Ben Barham
5343c72d10 [rebranch] Fix missing includes 2021-11-13 17:04:29 +10:00
Kuba (Brecka) Mracek
afe116b1d4 Also disable SwiftMergeFunctionsPass on top of LLVM MergeFunctions when VFE/WME is on (#40016) 2021-11-02 17:57:01 -07:00
Erik Eckstein
5321a7cae8 SIL: Only enable instruction leaks checking in the frontend's and SILOpt's modules.
Leaks checking is not thread safe and e.g. lldb creates multiple SILModules in multiple threads, which would result in false alarms.
Ideally we would make it thread safe, e.g. by putting the instruction counters in the SILModule, but this would be a big effort and it's not worth doing it. Leaks checking in the frontend's and SILOpt's SILModule (not including SILModules created for module interface building) is a good enough test.

rdar://84688015
2021-11-02 10:23:46 +01:00
Kuba (Brecka) Mracek
d682049d25 Under VFE/WME, disable mangled accessors and disable LLVM MergeFunctions (#39969) 2021-11-01 15:34:53 -07:00
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
swift-ci
3f8fea8508 Merge remote-tracking branch 'origin/main' into rebranch 2021-10-06 10:17:29 -07:00
Doug Gregor
2551a04621 Back-deploy @objc actor types.
@objc actors implicitly inherit from the new, hidden
`SwiftNativeNSObject` class that inherits from `NSObject` yet provides
Swift-native reference counting, which is important for the actor
runtime's handling of zombies. However, `SwiftNativeNSObject` is only
available in the Swift runtime in newer OS versions (e.g., macOS
12.0/iOS 15.0), and is available in the back-deployed _Concurrency
library, but there is no stable place to link against for
back-deployed code. Tricky, tricky.

When back-deploying @objc actors, record `NSObject` as the superclass
in the metadata in the binary, because we cannot reference
`SwiftNativeNSObject`. Then, emit a static initializer to
dynamically look up `SwiftNativeNSObject` by name (which will find it
in either the back-deployment library, on older systems, or in the
runtime for newer systems), then swizzle that in as the superclass of
the @objc actor.

Fixes rdar://83919973.
2021-10-05 23:04:57 -07:00
Kuba Mracek
2dfd232d90 Implement conditional stripping of type descriptors, protocols and protocol conformances via !llvm.used.conditional
A new LLVM IR affordance that allows expressing conditions under which globals
can be removed/dropped (even when marked with @llvm.used) is being discussed at:

- <https://reviews.llvm.org/D104496>
- <https://lists.llvm.org/pipermail/llvm-dev/2021-September/152656.html>

This is a preliminary implementation that marks runtime lookup records (namely
protocol records, type descriptors records and protocol conformance records)
with the !llvm.used.conditional descriptors. That allows link-time / LTO-time
removal of these records (by GlobalDCE) based on whether they're actually used
within the linkage unit. Effectively, this allows libraries that have a limited
and known set of clients, to be optimized against the client at LTO time, and
significantly reduce the code size of that library.

Parts of the implementation:
- New -conditional-runtime-records frontend flag to enable using !llvm.used.conditional
- IRGen code that emits these records can now emit these either as a single contiguous
  array (asContiguousArray = true, the old way), which is used for JIT mode, or
  as indivial globals (asContiguousArray = false), which is necessary for the
  !llvm.used.conditional stripping to work.
- When records are emitted as individual globals, they have new names of
  "\01l_protocol_" + mangled name of the protocol descriptor, and similarly for
  other records.
- Fixed existing tests to account for individual records instead of a single array
- Added an IR level test, and an end-to-end execution test to demonstrate that
  the !llvm.used.conditional-based stripping actually works.
2021-09-29 13:15:02 -07:00
swift-ci
64e7db3a76 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-21 07:13:27 -07:00
Kuba (Brecka) Mracek
46eb8d5db5 Implement LLVM IR Witness Method Elimination for Swift witness tables. (#39287)
- Witness method calls are done via @llvm.type.checked.load instrinsic call with a type identifier
- Type id of a witness method is the requirement's mangled name
- Witness tables get !type markers that list offsets and type ids of all methods in the wtable
- Added -enable-llvm-wme to enable Witness Method Elimination
- Added IR test and execution test
2021-09-21 06:57:44 -07:00
Nate Chandler
b4291916f2 Merge branch 'main' into rebranch
Conflicts:
        include/swift/SIL/SILBuilder.h
2021-09-15 13:30:12 -07:00
Arnold Schwaighofer
2381233ac1 Add flag -swift-async-framepointer=auto,never,always to
control swift extended frame information emission

On linux we default to disable the extended frame info (since the system
libraries don't support it).

On darwin the default is to automatically choose based on the deployment target.

The Concurrency library explicitly forces extended frame information and the
back deployment library explicitly disables it.
2021-09-14 12:47:16 -07:00
swift-ci
1d5a202148 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-14 07:14:26 -07:00
Kuba (Brecka) Mracek
5412ed1936 Implement LLVM IR Virtual Function Elimination for Swift classes. (#39128)
- Virtual calls are done via a @llvm.type.checked.load instrinsic call with a type identifier
- Type identifier of a vfunc is the base method's mangling
- Type descriptors and class metadata get !type markers that list offsets and type identifiers of all vfuncs
- The -enable-llvm-vfe frontend flag enables VFE
- Two added tests verify the behavior on IR and by executing a program
2021-09-14 06:59:07 -07:00
swift-ci
5ffe0c5401 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-19 09:13:25 -07:00
Arnold Schwaighofer
bf7d9108fb Disable GlobalISelAbort
When using GlobalISel instead of SelectionDAG lowering allow for
fall-back to SelectionDAG instead of aborting.
2021-08-18 13:08:18 -07:00
swift-ci
e30edb92c3 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-17 17:53:24 -07:00