Commit Graph

629 Commits

Author SHA1 Message Date
Kuba Mracek
e80cc2fb34 [embedded] Fix compilation crash with -num-threads and -mergeable-symbols 2025-03-31 11:23:50 -07:00
Arnold Schwaighofer
767c96f1fa Add setupLLVMOptimizationRemarks 2025-03-20 08:34:46 -07:00
nate-chandler
39f58de32e Merge pull request #80033 from nate-chandler/verify-each-flag
[IRGen] Add flags to control LLVM verify-each.
2025-03-17 07:35:17 -07:00
Nate Chandler
dd8c715aa6 [IRGen] Add flags to control LLVM verify-each.
Analogous to -sil-verify-all, the new flags cause LLVM verification to
be run after each LLVM optimization pass.
2025-03-14 17:51:43 -07:00
Nate Chandler
6581fec9e1 [CoroutineAccessors] PtrAuth. 2025-03-07 11:46:51 -08:00
Kuba Mracek
119d6e27d4 [IRGen] Expose an -Xfrontend flag to disable the LLVM MergeFunctions pass 2025-02-24 09:05:22 -08:00
Finagolfin
c69a12ce39 [android] Use emulated thread-local storage for API 28 and earlier
Android before API 29 and a few other platforms don't support native TLS, so
fall back to LLVM's emulated TLS there, just like clang does. Also, make sure
`-Xcc -f{no-,}emulated-tls` flags passed in are applied to control what the
Swift compiler does.
2024-12-30 23:07:58 +05:30
Antonio Frighetto
377c03fa7e [Driver][Frontend] Introduce load-pass-plugin option
Allow dynamic loading of LLVM passes via `load-pass-plugin`
option passed to the Swift compiler driver.
2024-11-07 17:25:24 +01:00
Kavon Farvardin
19e593bc07 PGO: new -debug-info-for-profiling frontend flag
This achieves the same as clang's `-fdebug-info-for-profiling`, which
emits DWARF discriminators to aid in narrowing-down which basic block
corresponds to a particular instruction address. This is particularly
useful for sampling-based profiling.

rdar://135443278
2024-11-01 11:59:54 -07:00
Kavon Farvardin
2b01714fba PGO: new -profile-sample-use= frontend flag
This is meant to match clang's `-fprofile-sample-use=` and accepts a
file with the same format.

rdar://135443278
2024-11-01 11:59:54 -07:00
swift-ci
8a2edbc4c5 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-11 17:05:06 -07:00
Nate Chandler
df1c4f6b25 [CoroutineAccessors] Add new SILFnTy CoroKind.
For `modify` and `read` coroutines, produce SILFunctionType's whose
coroutineKind is ::YieldOnce2.
2024-10-11 08:25:02 -07:00
swift-ci
753b917274 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-25 05:36:07 -07:00
Slava Pestov
0cd27bf7d9 IRGen: Add a FrontendStatsTracer
We didn't measure time spent in IRGen in multi-threaded mode previously.
2024-09-23 17:12:45 -04:00
Ben Barham
a7b50f357f Merge remote-tracking branch 'origin/main' into manual-main-merge
Conflicts:
  - `lib/Driver/ToolChains.cpp` conflicting with the `addAllArgs` rename
    for multiple options
2024-09-16 13:53:18 -07:00
Arnold Schwaighofer
eaf90dff38 IRGen: Add metadata for async funclets denoting frame entry and frame exists
Adds sections `__TEXT,__swift_as_entry`, and `__TEXT,__swift_as_ret` that
contain relative pointers to async functlets modelling async function entries,
and function returns, respectively.

Emission of the sections can be trigger with the frontend option
`-Xfrontend -enable-async-frame-push-pop-metadata`.

This is done by:

* IRGen adding a `async_entry` function attribute to async functions.
* LLVM's coroutine splitting identifying continuation funclets that
  model the return from an async function call by adding the function
  attribute `async_ret`.  (see #llvm-project/pull/9204)
* An LLVM pass that keys off these two function attribute and emits the
  metadata into the above mention sections.

rdar://134460666
2024-09-03 08:44:16 -07:00
swift-ci
aa1688e468 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-25 18:34:28 -07:00
Kavon Farvardin
1c3ef6c51d ColdSplit: avoid with -Osize
Based on prior evaluation, this optimization always increases code
size. It splits out blocks and introduces calls, which always adds
extra instructions to shuffle values for calling conventions and
to make the actual call/return. Apple clang avoids the optimization
in `-Oz`, which I think is pretty close to what Swift's `-Osize`
really means.
2024-08-25 13:56:58 -07:00
Ben Barham
467e528200 Merge remote-tracking branch 'origin/main' into manual-rebranch-merge
Conflicts:
  - `lib/Serialization/ModuleFormat.h` bumped version to account for
    differences between main and rebranch.
2024-08-09 15:22:39 -07:00
Kavon Farvardin
9d69f2bceb Merge pull request #75382 from kavon/static-branch-prediction
Throws Prediction + HotColdSplitting
2024-08-09 15:24:22 -04:00
Kavon Farvardin
11e8bb8759 IRGen: -enable-split-cold-code frontend feature 2024-08-09 12:09:29 -04:00
swift-ci
f1ea924a51 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-24 10:14:18 -07:00
Allan Shortlidge
bb8a837dcf IRGen: Honor -target-variant flag for zippered macCatalyst binaries. 2024-07-23 17:00:10 -07:00
swift-ci
81a582e9f7 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-15 15:34:55 -07:00
Dario Rexin
14df7a1db9 Merge pull request #75246 from drexin/wip-131352085
Revert "[IRGen] Fetch the correct IGM for synthesized files"
2024-07-15 15:32:15 -07:00
Dario Rexin
a401d15ea5 Revert "[IRGen] Fetch the correct IGM for synthesized files"
rdar://131352085

This change caused the problems it was supposed to fix for Macros to appear with Differentiation.

This reverts commit d33f2c4ba1.
2024-07-15 10:47:42 -07:00
swift-ci
0be42b6b18 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-11 06:14:58 -07:00
Slava Pestov
403bb98451 AST: Optimize collectLinkLibraries()
SourceFile::collectLinkLibraries() did not depend on the source file,
so let's move this logic up into ModuleDecl::collectLinkLibraries().
2024-07-10 23:06:22 -04:00
swift-ci
1c7daa9a91 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-01 14:38:34 -07:00
Egor Zhdan
75a00adcf0 Merge pull request #74625 from swiftlang/egorzhdan/upstream-ptrauth-vwt
[IRGen] Upstream pointer auth for value witness tables
2024-07-01 22:17:59 +01:00
Egor Zhdan
b22057e637 [IRGen] Upstream pointer auth for value witness tables
This makes Swift emit a signed pointer to the value witness table in type metadata.

The original change was done by Varun Gandhi.
2024-07-01 16:38:06 +01:00
swift-ci
147a2a7947 Merge remote-tracking branch 'origin/main' into rebranch 2024-06-29 07:34:58 -07:00
Dario Rexin
d33f2c4ba1 [IRGen] Fetch the correct IGM for synthesized files
rdar://128870792

Synthesized files are treated as not having a parent source file, but that can cause issues for macro code. The declarations will have the source file of their use site declared as parent source file, which means they should be emitted into the same IGM. If we don't use the correct IGM, we can get inconsistencies when referencing the generated code, which will cause linking issues.
2024-06-28 11:07:38 -07:00
Xi Ge
736ccef626 Merge remote-tracking branch 'apple/main' into rebranch 2024-06-20 15:16:55 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
swift-ci
caf307833c Merge remote-tracking branch 'origin/main' into rebranch 2024-05-04 01:34:28 -07:00
Alastair Houghton
a363719434 [IRGen] Set TargetOpts.UseInitArray in getIRTargetOptions().
IRGen sets up the `llvm::TargetOptions` by itself, rather than copying
them from the Clang instance (it has to do this, at present, because
Clang doesn't provide a way to get it to initialise one).

Unfortunately, it didn't set `UseInitArray`, which when linking with
GNU `ld` or `gold` is *fine* because those linkers automatically
convert `.ctors` and `.dtors` sections into `.init_array` and
`.fini_array` respectively.  *However*, `lld` does *not* do this
conversion, so when using `lld`, if the compiler generates a
constructor or destructor function, it won't be called(!)

The fix is to set `UseInitArray` properly; I chose to copy the setting
from Clang, just in case Clang knows of a reason why it shouldn't be
`true`.

rdar://123504095
2024-04-29 10:48:22 +01:00
Alastair Houghton
0a5653dbaf [IRGen] When creating a module object, mark __Swift_AST as used.
Without doing this, `__Swift_AST` gets stripped from the output.
We also need to call `IGM.finalize()` before `::performLLVM()` in the
`createSwiftModuleObjectFile()` function, so that we update the
section to mark it as retained.

rdar://123504095
2024-04-29 10:48:22 +01:00
swift-ci
5b6eadf416 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-12 13:37:42 -07:00
Ben Barham
9fc775c5fb [IRGen] Rename InstrProfiling to InstrProfilingLoweringPass
This was refactored in LLVM 90893a3b3f71524947cb041b2a25d0a02a8956d7,
with `InstrProfiling` becoming implementation details.
2024-04-08 08:58:59 -07:00
Ben Barham
0f52071c22 Fix up various references to renamed/moved enums
A bunch of enums were moved to enum classes and slightly renamed. Fix up
their references.
2024-04-08 08:58:58 -07:00
Arnold Schwaighofer
917ae2d051 LargeTypesReg2Mem: Forward the address of large formally by-val arguments and return values of C functions
rdar://47978338
2024-04-02 13:11:16 -07:00
Dario Rexin
b62091695e [IRGen] Fix diagnostic for CVW disablement through block list (#72624)
rdar://125486631
2024-03-27 16:12:47 -07:00
Dario Rexin
8e72a01616 [IRGen] Add ability to disable compact value witnesses from block list (#72335)
rdar://124629183

Allows usage of compact value witnesses to be disabled using a block list.
2024-03-20 12:53:35 -07:00
Erik Eckstein
3488cd364f SIL: remove instruction leaks checking
It's not thread safe and can cause false alarms in case multiple modules exist in different threads. E.g. when building swiftmodules from interfaces.
The leaking check is not important anymore because the builder APIs enforce that instructions are not leaking.
I.e. it's not possible to create an instruction without inserting it into a basic block. Also, it's not possible to remove an instruction from a block without deleting it.

rdar://122169263
2024-02-22 14:09:11 +01:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Kavon Farvardin
74a3839cf3 Merge pull request #71515 from kavon/ncgenerics-test-fixes-kavon-v7
Ncgenerics test fixes kavon v7
2024-02-09 19:39:18 -08:00
Slava Pestov
06b1aee360 Evaluator: Cache circular evaluation to avoid redundant diagnostics
Previously, if a request R evaluated itself N times, we would emit N
"circular reference" diagnostics. These add no value, so instead let's
cache the user-provided default value on the first circular evaluation.

This changes things slightly so that instead of returning an
llvm::Expected<Request::OutputType>, various evaluator methods take
a callback which can produce the default value.

The existing evaluateOrDefault() interface is unchanged, and a new
evaluateOrFatal() entry point replaces
llvm::cantFail(ctx.evaluator(...)).

Direct callers of the evaluator's operator() were updated to pass in
the callback. The benefit of the callback over evaluateOrDefault() is
that if the default value is expensive to constuct, like a dummy
generic signature, we will only construct it in the case where a
cycle actually happened, otherwise we just delete the callback.

(cherry picked from commit b8fcf1c709efa6cd28e1217bd0efe876f7c0d2b7)
2024-02-09 16:02:24 -08:00
Arnold Schwaighofer
61326af56d Merge pull request #71414 from aschwaighofer/coro_noinline
IRGen: Mark async intrinsic helper functions as always inline
2024-02-08 12:46:03 -08:00
Arnold Schwaighofer
bc81d23102 IRGen: Mark async intrinsic helper functions as always inline
github.com/apple/swift/issues/68708
rdar://115905828
2024-02-06 11:09:06 -08:00