Commit Graph

629 Commits

Author SHA1 Message Date
Arnold Schwaighofer
71f64ac348 Add option to enable global-isel on arm64 archs
LLVM will eventually switch over to using global-isel on arm64 archs.
Setting this option (SWIFT_ENABLE_GLOBAL_ISEL_ARM64) can be used to experiment
with that in Swift before the switch happens.
2021-08-17 13:41:46 -07:00
Evan Wilde
b1ea839b1d Merge branches 'ewilde/rebranch/printHelp', 'ewilde/rebranch/vkrvalue', 'ewilde/rebranch/datalayout', 'ewilde/rebranch/withNullAsEmpty', 'ewilde/rebranch/format', 'ewilde/rebranch/collectUsedGlobals' and 'ewilde/rebranch/SILSerialization' into ewilde/swift-rebranch 2021-07-08 17:48:06 -07:00
Evan Wilde
5a1b0f82e1 Fix call to collectUsedGlobalVariables
LLVM commit 3adb89bb9f8e73c82787babb2f877fece7394770 updated the API of
this function to take a reference to a `SmallVectorImpl` instead of a
set to ensure that it behaves deterministically.
2021-07-08 17:38:52 -07:00
Evan Wilde
1e6787925f Fix IRGen datalayout
Same issue as with TBDGen. Clang doesn't hold onto the Datalayout object
anymore, but instead keeps the description string that is constructed on
the fly. This patch updates IRGen to behave the same way.
2021-07-08 16:59:11 -07:00
Evan Wilde
0aafd09835 F_None was renamed OF_None
This patch updates usages of F_None to OF_None, as LLVM changed that in
commit 3302af9d4c39642bebe64dd60a3aa162fefc44b2.
2021-06-23 10:36:39 -07:00
Nate Chandler
d765434e2b [IRGen] Restored non-constant async function calls in PAFs.
Previously, because partial apply forwarders for async functions were
not themselves fully-fledged async functions, they were not able to
handle dynamic functions.  Specifically, the reason was that it was not
possible to produce an async function pointer for the partial apply
forwarder because the size to be used was not knowable.

Thanks to https://github.com/apple/swift/pull/36700, that cause has been
eliminated.  With it, partial apply forwarders are fully-fledged async
functions and in particular have their own async function pointers.
Consequently, it is again possible for these partial apply forwarders to
handle non-constant function pointers.

Here, that behavior is restored, by way of reverting part of
ee63777332 while preserving the ABI it
introduced.

rdar://76122027
2021-04-06 15:51:32 -07:00
Nate Chandler
d3e0e7af07 [ptrauth] Signed AsyncFunctionPointers as data.
Previously, AsyncFunctionPointer constants were signed as code.  That
was incorrect considering that these constants are in fact data.  Here,
that is fixed.

rdar://76118522
2021-04-05 18:24:41 -07:00
Varun Gandhi
cc14992281 [Frontend] Add -emit-irgen option to driver and frontend.
Fixes SR-14389, fixes rdar://75715690.
2021-03-31 11:56:36 -07:00
Nate Chandler
c31cb54d35 [IRGen] Sign TaskResumeContext. 2021-02-03 17:50:50 -08:00
swift-ci
9d0d1fff60 Merge remote-tracking branch 'origin/main' into rebranch 2021-01-26 06:12:31 -08:00
Arnold Schwaighofer
daa72d3cc5 Add llvm::Attribute::SwiftAsync to the context parameter
* Adds support for generating code that uses swiftasync parameter lowering.

* Currently only arm64's llvm lowering supports the swift_async_context_addr intrinsic.

* Add arm64e pointer signing of updated swift_async_context_addr.

This commit needs the PR llvm-project#2291.

* [runtime] unittests should use just-built compiler if the runtime did

This will start to matter with the introduction of usage of swiftasync parameters which only very recent compilers support.

rdar://71499498
2021-01-22 10:01:55 -08:00
swift_jenkins
de9e56fb12 Merge remote-tracking branch 'origin/main' into next 2020-12-16 19:43:18 -08:00
Dan Liew
8e95189d24 Merge pull request #35074 from apple/dliew/rdar-69335186
Disable "UseOdrIndicator" ASan instrumentation mode by default.
2020-12-16 19:19:40 -08:00
swift_jenkins
167386c104 Merge remote-tracking branch 'origin/main' into next 2020-12-15 12:42:57 -08:00
Dan Liew
9208b52de1 Disable "UseOdrIndicator" ASan instrumentation mode by default.
Previously Swift enabled the "UseOdrIndicator" ASan instrumentation mode
and gave no option to disable this. This probably wasn't intentional but
happened due to the fact the
`createModuleAddressSanitizerLegacyPassPass()` function has a default
value for the `UseOdrIndicator` parameter of `true` and in Swift we
never specified this parameter explicitly.

Clang disables the "UseOdrIndicator" mode by default but allows it to be
enabled using the `-fsanitize-address-use-odr-indicator` flag.
Having "UseOdrIndicator" off by default is probably the right
default choice because it bloats the binary. So this patch changes the
Swift compiler to match Clang's behavior.

This patch disables the "UseOdrIndicator" mode by default but adds a
hidden driver and frontend flag (`-sanitize-address-use-odr-indicator`)
to enable it. The flag is hidden so that we can remove it in the future
if needed.

A side effect  of disabling "UseOdrIndicator" is that by we will no
longer use private aliases for poisoning globals. Private aliases were
introduced to avoid crashes
(https://github.com/google/sanitizers/issues/398) due to ODR violations
with non-instrumented binaries. On Apple platforms the use of two-level
namespaces probably means that using private aliases wasn't ever really
necessary to avoid crashes. On platforms with a flat linking namespace
(e.g. Linux) using private aliases might matter more but should users
actually run into problems they can either:

* Fix their environment to remove the ODR, thus avoiding the crash.
* Instrument the previously non-instrumented code to avoid the crash.
* Use the new `-sanitize-address-use-odr-indicator` flag

rdar://problem/69335186
2020-12-15 11:09:30 -08:00
Erik Eckstein
e697e49582 [concurrency] IRGen:: do ptrauth for hop_to_executor
Sign the resume-function pointer which is stored in AsyncTask.ResumeTask
2020-12-15 15:23:20 +01:00
swift_jenkins
eade12ccaa Merge remote-tracking branch 'origin/main' into next 2020-12-07 08:50:18 -08:00
Nate Chandler
b0913fd829 [PtrAuth] Corrected AsyncContextParent schema.
Previously, the schema used a key intended for pointers to code.  An
AsyncContextParent is actually a pointer to data, so that key was
incorrect.  Here, that error is corrected and the schema now uses the
key for pointers to data.
2020-12-04 16:36:37 -08:00
Nate Chandler
d4be3e88e4 [PtrAuth] Adopt AsyncContextResume schema. 2020-12-04 16:36:36 -08:00
swift_jenkins
3e5db601d7 Merge remote-tracking branch 'origin/main' into next 2020-11-02 10:06:47 -08:00
Nate Chandler
c502e97a25 [Async CC] Auth'd parent context pointer. 2020-10-28 12:48:54 -07:00
Erik Eckstein
69edd5020a Merge remote-tracking branch 'origin/main' into next 2020-10-03 21:10:11 +02:00
John McCall
e1004499c4 [NFC] Split ProtocolDispatchStrategy out of MetadataValues.h.
This allows us to avoid rebuilding most of the compiler
whenever we add a new ABI constant.
2020-10-03 02:26:17 -04:00
swift_jenkins
b1fa15fe87 Merge remote-tracking branch 'origin/main' into next 2020-09-29 23:14:40 -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
swift_jenkins
75c4b09f51 Merge remote-tracking branch 'origin/master' into master-next 2020-09-15 15:41:58 -07:00
Hamish Knight
088a86eccb Introduce SymbolObjectCodeRequest
Add SymbolObjectCodeRequest, which emits object
code for a specific set of symbols by querying
TBDGen for the source of the symbols, and asking
SILGen (and eventually IRGen) to emit them.
2020-09-15 19:20:11 +01:00
Hamish Knight
44a8b56168 Rename getFiles to getFilesToEmit
Rename the member on ASTLoweringDescriptor and
IRGenDescriptor to make it more explicit it returns
the files that need emitting, rather than just the
files that happen to be present. This distinction
will become important once we start emitting code
only for a specific set of symbols.
2020-09-15 19:20:10 +01:00
Hamish Knight
add22194fd [SILGen] Allow lazy type-checking
Remove the type-checking call from
OptimizedIRRequest, and sink it down into SILGen
and IRGen when we come to emit the source files.
2020-09-15 19:20:10 +01:00
swift_jenkins
59f861034d Merge remote-tracking branch 'origin/master' into master-next 2020-09-11 05:35:11 -07:00
Erik Eckstein
56c857afa9 SIL: Check for leaked instructions in the SILVerifier and in the SILModule destructor. 2020-09-11 11:09:30 +02:00
David Zarzycki
00f4700496 Handle expanded enums in upstream LLVM (ZOS and GOFF) 2020-08-12 09:05:38 -04:00
Hamish Knight
9f47a284be Merge pull request #33159 from hamishknight/back-to-the-future
Introduce LoweredSILRequest
2020-07-28 21:30:42 -07:00
Hamish Knight
a99f8e9d9c Introduce LoweredSILRequest
Add a request that produces lowered SIL for a file
or module and use it in IRGenRequest if no
SILModule is provided.
2020-07-28 10:37:37 -07:00
Saleem Abdulrasool
8e86d0fbbd IRGen: always execute the coroutine lowering pass
Do not gate the coroutine extension points on the LLVM passes. Without
running this pass, the generated IR cannot be used by the LLVM tooling.
This allows generating the LLVM IR to debug issues in the LLVM backend.

I encountered this when trying to isolate a debug info generation bug
which seems to be caused by the SRoA pass in LLVM. By allowing to emit
the LLVM IR without the LLVM optimizations, it is possible to isolate
the LLVM pass operation via `opt` from LLVM.
2020-07-27 23:17:30 +00:00
Robert Widmann
638977454b Remove SharedTimer Infrastructure
Teach the UnifiedStatsReporter to directly construct
llvm::NamedRegionTimer for itself.
2020-07-16 17:35:50 -07:00
Hamish Knight
485d5e9bb4 [IRGen] Introduce OptimizedIRRequest
Introduce a request that wraps the entire compiler
pipeline and returns the optimized IR for a
whole-module or file.
2020-07-15 16:46:42 -07:00
Hamish Knight
d05bfa09d6 [IRGen] Lift call to performLLVM out of IRGenRequest
Remove the side-effecting call from IRGenRequest,
instead requiring callers to handle the optimization
and emission of the LLVM module.
2020-07-15 16:46:42 -07:00
Hamish Knight
408b6fcf3f [IRGen] Factor out compileAndWriteLLVM
Factor out the logic that deals with the LLVM
passes for compiling and emitting the module.
2020-07-15 16:46:42 -07:00
Hamish Knight
53ef0a2312 [IRGen] Move ObjCARCContractPass into performLLVMOptimizations
This seems like something we want to always do, not
just when emitting the LLVM module.
2020-07-15 16:46:41 -07:00
Hamish Knight
f9d70661dd [IRGen] Hash compiler version instead of lang version
The LLVM passes we apply don't depend on the language
version, only the compiler version.
2020-07-15 16:46:41 -07:00
Hamish Knight
45f11c8615 [IRGen] Allow IRGenDescriptor to hold a FileUnit
This will allow it to better interact with the
SILGen descriptor.
2020-07-15 16:46:41 -07:00
Hamish Knight
db7fea4665 Sink linker directive computation into IRGen
With an inverted pipeline, IRGen needs to be able
to compute the linker directives itself, so sink
it down such that it can be computed by the
`IRGenDescriptor`.
2020-07-13 20:42:54 -07:00
Hamish Knight
24dc744ca5 Have performParallelIRGeneration take an IRGenDescriptor 2020-07-13 20:42:53 -07:00
nate-chandler
69ff5be8ca Merge pull request #32791 from nate-chandler/generic-metadata-prespecialization-components/consider-conformances-ptrauth
[metadata prespecialization] Ptrauth for compared protocol conformances.
2020-07-09 16:10:02 -07:00
Nate Chandler
2701a0809b [metadata prespecialization] Ptrauth for compared protocol conformances.
Two protocol conformance descriptors are passed to
swift_compareProtocolConformanceDecriptors from generic metadata
accessors when there is a canonical prespecialization and one of the
generic arguments has a protocol requirement.

Previously, the descriptors were incorrectly being passed without
ptrauth processing: one from the witness table in the arguments that are
passed in to the accessor and one known statically.

Here, the descriptor in the witness table is authed using the
ProtocolConformanceDescriptor schema.  Then, both descriptors are signed
using the ProtocolConformanceDescriptorsAsArguments schema.  Finally, in
the runtime function, the descriptors are authed.
2020-07-09 11:45:16 -07:00
Yuta Saito
20bc0af42b [LTO] Support LLVM LTO for IRGen and frontend
This commit adds -lto flag for frontend to enable LTO at LLVM level.
When -lto=llvm given, compiler emits LLVM bitcode file instead of object
file and adds index summary for LTO.
In addition for ELF format, emit llvm.dependent-libraries section to
embed auto linking information
2020-07-01 23:30:58 +00:00
Hamish Knight
bf2f4af827 NFC: Move NumThreads from SILOptions to IRGenOptions
The option is only needed for IRGen.
2020-07-01 09:43:52 -07:00
Hamish Knight
c65246f74f Merge the IRGen requests
Similar to SILGen, merge `IRGenSourceFileRequest`
and `IRGenWholeModuleRequest` into a single
`IRGenRequest`.
2020-07-01 09:43:51 -07:00
Hamish Knight
fa715820a9 [IRGen] Assert the SourceFile has been type-checked 2020-07-01 09:43:51 -07:00