Commit Graph

643 Commits

Author SHA1 Message Date
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
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