Commit Graph

655 Commits

Author SHA1 Message Date
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08:00
Arnold Schwaighofer
1dfc30eb1f Merge remote-tracking branch 'origin/main' into rebranch 2023-02-27 09:18:56 -08:00
Dario Rexin
a8d4d57f11 [IRGen] Generate compressed representation of value witnesses (#63813)
rdar://105837040

* WIP: Store layout string in type metadata

* WIP: More cases working

* WIP: Layout strings almost working

* Add layout string pointer to struct metadata

* Fetch bytecode layout strings from metadata in runtime

* More efficient bytecode layout

* Add support for interpreted generics in layout strings

* Layout string instantiation, take and more

* Remove duplicate information from layout strings

* Include size of previous object in next objects offset to reduce number of increments at runtime

* Add support for existentials

* Build type layout strings with StructBuilder to support target sizes and metadata pointers

* Add support for resilient types

* Properly cache layout strings in compiler

* Generic resilient types working

* Non-generic resilient types working

* Instantiate resilient type in layout when possible

* Fix a few issues around alignment and signing

* Disable generics, fix static alignment

* Fix MultiPayloadEnum size when no extra tag is necessary

* Fixes after rebase

* Cleanup

* Fix most tests

* Fix objcImplementattion and non-Darwin builds

* Fix BytecodeLayouts on non-Darwin

* Fix Linux build

* Fix sizes in linux tests

* Sign layout string pointers

* Use nullptr instead of debug value
2023-02-24 15:40:28 -08:00
swift-ci
e2b5e98b83 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-20 19:13:32 -08:00
Arnold Schwaighofer
1fa68ff82b Sign relative protocol witness tables
rdar://98583748
2023-02-20 12:29:13 -08:00
swift-ci
f476abf4a1 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-20 17:13:36 -08:00
Pavel Yaskevich
c4cacd10d2 Merge pull request #62426 from xedin/runtime-discoverable-attrs
[Sema/SILGen/IRGen] Implement runtime discoverable attributes (under flag)
2022-12-20 16:54:28 -08:00
swift-ci
c4d4b9af7a Merge remote-tracking branch 'origin/main' into rebranch 2022-12-20 10:14:49 -08:00
Pavel Yaskevich
5442d30866 [IRGen] RuntimeMetadata: Emit runtime discoverable attributes section
Each entry relates an attribute declaration to a list of all
declarations it's associated with together with a generator
function to acquire instance of the attribute value.
2022-12-20 09:45:01 -08:00
Valeriy Van
eb750a6596 Fix possible memory leak 2022-12-18 00:45:16 +02:00
Ben Barham
68d5d1f9ca Merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
  lib/Frontend/CompilerInvocation.cpp - legacy pass manager removed
2022-12-07 10:13:47 -08:00
Hamish Knight
6d3545f4d5 [IRGen] Don't emit multiple copies of coverage maps
Iterating over the IRGenModules and emitting every
SILCoverageMap in the SILModule meant that we
were emitting N copies of the coverage maps for
parallel IRGen, where N is the number of output
object files.

This has always been wrong, but was previously
saved by the fact that we would drop the coverage
map on the floor if we didn't have the name data
available. This would only be the case for the
IRGenModule that had the emitted entity to
profile, in addition to any IRGenModules that
had inlined the body of a profiled enitity. As
such, this prevented the duplication from being
too egregious. However with the recent change to
emit unused name data in the case where we don't
already have name data available, we're now fully
duplicating every coverage mapping, and emitting a
ton of redundant name data.

Fix things such that we only emit coverage mapping
records for the IRGenModule that corresponds to
the entity being profiled.

rdar://102905496
2022-12-06 14:28:35 +00:00
swift-ci
efef52a86e Merge remote-tracking branch 'origin/main' into rebranch 2022-11-28 09:33:40 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Rintaro Ishizaki
d458c8b74a Merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
	include/swift/Sema/ConstraintSystem.h
	include/swift/Syntax/AbsoluteRawSyntax.h
	include/swift/Syntax/Syntax.h
	include/swift/Syntax/SyntaxData.h
	lib/DependencyScan/ModuleDependencyCacheSerialization.cpp
	lib/Syntax/SyntaxFactory.cpp.gyb
	lib/Syntax/SyntaxNodes.cpp.gyb
	tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
	tools/swift-syntax-test/swift-syntax-test.cpp
2022-11-18 09:37:38 -08:00
Allan Shortlidge
ae32b8e148 IRGen: Implement lowering of has_symbol SIL instruction. 2022-11-16 16:07:29 -08:00
Erik Eckstein
4c65062bdf rebranch: change some uses of Optional to the new API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

This change does not cover all uses of the old API. Other warnings are worked around in llvm by https://github.com/apple/llvm-project/pull/5618

rdar://102362022
2022-11-15 17:23:07 +01:00
swift-ci
b160fca1ac Merge remote-tracking branch 'origin/main' into rebranch 2022-11-04 17:04:49 -07:00
Erik Eckstein
aaa5cfb07f IRGen: workaround a build error due to changed LTO passes
TODO: fix this

IRGen: Adjust lto/thin-lto to the new pass manager way of doing things
2022-11-04 20:44:19 +01:00
Erik Eckstein
0c90c1b893 IRGen: rename some LLVM passes 2022-11-04 20:44:19 +01:00
Erik Eckstein
d812cd2efe IRGen: remove a not needed an not available include 2022-11-04 20:44:19 +01:00
Erik Eckstein
2653264b3c IRGen: remove the legacy pass manager 2022-11-04 20:44:18 +01:00
Allan Shortlidge
7f20380f0b IRGen: Generate #_hasSymbol query functions.
For each decl that needs a `#_hasSymbol()` query function, emit the corresponding helper function body during IRGen. Use `IRSymbolVisitor` to collect linkable symbols associated with the decl and return true from the helper function if the address of every associated symbol is non-null.

Resolves rdar://101884587
2022-11-04 11:19:29 -07:00
Allan Shortlidge
41269e6895 TBDGen: Merge TBDGen library into IRGen.
The relationship between the code in these two libraries was fundamentally circular, indicating that they should not have been split. With other changes that I'm making to remove circular dependencies from the CMake build graph I eventually uncovered that these two libraries were required to link each other circularly, but that had been hidden by other cycles in the build graph previously.
2022-10-27 11:28:02 -07:00
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