Commit Graph

38 Commits

Author SHA1 Message Date
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
Evan Wilde
df30fffcd1 Remove dbg addr intrinsic splitting pass
The llvm DbgAddr intrinsic was removed upstream, removing the DbgAddr
block splitting pass to get the compiler building.
2023-07-17 10:53:42 -07:00
Erik Eckstein
99685164e1 LLVMPasses: fix SwiftAAResult
TODO:  how to construct a SimpleAAQueryInfo without an AAResults?
2022-11-04 20:44:18 +01:00
Arnold Schwaighofer
5c9eab0f6c Update Swift's LLVM passes to include new pass manager versions 2022-07-15 08:22:32 -07: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
Saleem Abdulrasool
2b9a9e4bd6 LLVMPasses: adapt to ba664d9
Adapt to API changes in ba664d9, where `AAQueryInfo` now requires the
capturing information.  Switch to the new `SimpleAAQueryInfo` which
maintains the status quo for alias analysis.
2021-09-27 17:15:11 -07:00
Erik Eckstein
e4e5484ab4 LLVM-Passes: add pointer authentication to Swift's function merge pass.
If during merging a function pointer is passed as a parameter to the merged function, it needs to be signed on arm64e.

rdar://problem/66797689
2020-09-23 16:25:17 +02:00
Jonas Devlieghere
2ab36e22f9 Adjust for upstream LLVM changes 2019-11-15 17:08:49 -08:00
Michael Gottesman
36b9cac6a1 [upstream-update] Add to SwiftAAResult a getModRefInfo entrypoint that takes an llvm::AAQueryInfo.
I left in the old entrypoint as well that doesn't take the AAQueryInfo by having
it delegate to the AAQueryInfo entrypoint passing a default constructed
AAQueryInfo. This matches how people upstream have handled this.

rdar://49450147
2019-04-09 10:50:38 -07:00
Bob Wilson
8c2f7a352d master-next: Adjust for LLVM r350503
LLVM's Alias Analysis APIs were changed to use a new CallBase class
instead of the CallSite wrapper
2019-01-10 15:39:22 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Erik Eckstein
bd0d2bfed4 Remove the LLVM stack promotion pass and related SIL optimization logic.
It's not needed anymore because array buffers are now allocated with alloc_ref instead of a swift_bufferAllocate runtime call.
2016-09-16 11:02:19 -07:00
Dmitri Gribenko
fbb3cf35a5 Revert "New SIL instructions to support tail-allocated arrays in SIL." 2016-09-15 00:25:25 -07:00
Erik Eckstein
6ae818c9d1 Remove the LLVM stack promotion pass and related SIL optimization logic.
It's not needed anymore because array buffers are now allocated with alloc_ref instead of a swift_bufferAllocate runtime call.
2016-09-14 14:54:18 -07:00
Saleem Abdulrasool
f363c5496e [upstream-update] update AA interface usage
SVN r262490 reformulated the Alias Analysis interfaces.  The TLI is no longer
needed to construct the AA Result.  Because the TLI was used specifically for
the base constructor, we now no longer need that option.  Simplify it according
to the new API.  NFC.

(cherry picked from commit 12dc8a831c)
(cherry picked from commit 270a4c240781e012a1c0d63c581102707130e02b)
2016-05-13 22:03:24 -07:00
Erik Eckstein
f0022a5aac Add an LLVM pass to merge similar functions.
It's like LLVM's MergeFunctions pass, except that it can also merge functions which differ by some constants.
The intention is to merge specialized functions which only differ by metadata lookups. But it can also merge other types of functions.
It gives ~7% code size reducation for the stdlib.

There are still some open TODOs, e.g. to share common code with LLVM's MergeFunctions pass (currently much code is just copied).
2016-05-11 09:46:46 -07:00
Erik Eckstein
9e28192ea3 Option -print-llvm-inline-tree for printing the inline-tree of the LLVM module.
This is useful to get information about what inlined functions contribute to the code size.
2016-02-10 12:14:23 -08:00
practicalswift
71e00fefa1 [gardening] Fix typos: "word word" (two spaces) → "word word" (one space) 2016-01-24 21:27:16 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Erik Eckstein
ce848c648d And again: re-apply the StackPromotion commit 0dd045ca04.
The problem of the failure was a bug in instruction cloning, which is fixed in the previous commit.
2015-11-08 15:51:00 -08:00
Mark Lacey
e9718f619e Revert "Another try to re-apply the StackPromotion commit 0dd045ca04dcc10a33abf57f7e1b08260c4e3de1."
This reverts commit 7d70aa39dc because
it may be responsible for a bot breakage.
2015-11-07 16:51:24 -08:00
Erik Eckstein
7d70aa39dc Another try to re-apply the StackPromotion commit 0dd045ca04.
One bug fixed in escape analysis (previous commit) and one bug fixed in StackPromotion itself.
2015-11-06 16:16:36 -08:00
Arnold Schwaighofer
fd662987c8 Revert the StackPromotion pass - bots hit an assert.
Assertion failed: (NumUsePointsToFind > 0 && "There must be at least one
releasing instruction for an alloc"), function canPromoteAlloc

Revert "Fix comment for StackPromotion pass in SIL Passes"
Revert "Reapply the StackPromotion commit
0dd045ca04dcc10a33abf57f7e1b08260c4e3de1."

This reverts commit 3f4b1496bd and commit
199cfca13b.
2015-11-06 06:40:05 -08:00
Erik Eckstein
199cfca13b Reapply the StackPromotion commit 0dd045ca04.
This time with fixing a crash.
2015-11-05 22:01:27 -08:00
Erik Eckstein
d7b7fc76ea Revert "Add a stack promotion optimization."
This reverts commit 0dd045ca04.

StackPromotion crashes when compiling MatMult in stdlib-asserts configuration
2015-11-05 21:34:05 -08:00
Erik Eckstein
0dd045ca04 Add a stack promotion optimization.
It promotes allocations of native swift objects and array buffers to the stack if it is possible.
The SIL StackPromotion pass is the main part of the optimization. For details see comments there.
Unfortunately we need an additional LLVM pass to handle array buffers, which is not very nice.
I hope that we can get rid of it in future (again: for details see the comments in StackPromotion.cpp)

The optimization gives performance improvements in some benchmarks, mostly related to array literals:
ArrayLiteral: +12%
Combos: +16%
DictionaryLiteral: + 37%
RIPEMD: +10%
StringBuilder: +27%
StringInterpolation: +11%
And last but not least the new benchmark which is dedicated to test stack promotion:
ObjectAllocation: +52%
2015-11-05 16:52:59 -08:00
Michael Gottesman
9ebc0d214b Move the declaration of initializeSwiftARCContractPass and initializeSwiftARCOptPass from {LLVMARCContarct,LLVMARCOpts}.cpp => PassesFwd.h so swift-llvm-opts can use them.
Swift SVN r32807
2015-10-21 21:45:19 +00:00
Michael Gottesman
26337f291d Move declaration of initializeSwiftAAWrapperPassPass and initializeSwiftRCIdentityPass from Passes.h => PassesFwd.h.
Swift SVN r32806
2015-10-21 21:45:19 +00:00
Michael Gottesman
72f5063f3c Update SwiftAA for upstream AA changes.
Swift SVN r32800
2015-10-21 21:45:13 +00:00
Xin Tong
ecc7cc091c Use LLVM RC Identity for LLVMARCOpt Retain/Release code motion.rdar://22774326
Swift SVN r32146
2015-09-22 05:58:07 +00:00
Xin Tong
c9f43c824c LLVM level RC identity, strip off pointer casts as well as reference forwarding
for some of the entry points. rdar://22774326

Swift SVN r32124
2015-09-21 21:16:22 +00:00
Michael Gottesman
72f7476ce9 Adjust to upstream changes in the ModRefResult enum
Swift SVN r31799
2015-09-09 04:37:15 +00:00
Michael Gottesman
2315c8fd06 [llvm-arc-opts] Rename SwiftARCExpand => SwiftARCContract.
This pass does things similar to LLVMARCContract so it makes sense to use the
same naming schema.

Also I am going to be implementing some contracting optimziations here later
today.

Swift SVN r30203
2015-07-15 00:03:01 +00:00
Dmitri Hrybenko
8f61538f64 Adjust to llvm::Location -> llvm::MemoryLocation rename
Swift SVN r29698
2015-06-25 22:01:36 +00:00
Andrew Trick
af711933b7 Update DataLayout API for upstream LLVM changes.
Swift SVN r25771
2015-03-04 23:21:47 +00:00
Michael Gottesman
1f9e654def Split lib/LLVMPasses/Passes.cpp into LLVMARCOpts.cpp and LLVMSwiftAA.cpp.
Swift SVN r21655
2014-09-02 21:14:21 +00:00
Michael Gottesman
4c953d7f33 Rename OptimizeARC library => LLVMPasses library.
OptimizeARC does not only contain an optimize arc pass: the library also
includes aa. What this really is a repository of the extra passes and
infrastructure that we inject into LLVM. Thus LLVMPasses is a more descriptive
name. It also matches SILPasses.

I also taught lit how to use the new llvm-opt driver for running swift llvm
passes through opt without having to remember how to setup the dynamic swift
llvm pass dylib. You can use this in lit tests by using the substitution
%llvm-opt.

Swift SVN r21654
2014-09-02 20:51:40 +00:00