Commit Graph

101 Commits

Author SHA1 Message Date
Kuba Mracek
84c4864911 [arm64e] Add Swift compiler support for arm64e pointer authentication 2020-02-27 16:10:31 -08:00
Jonas Devlieghere
4db7f40686 Update for upstream intrinsics change (NFC)
The Intrinsic ID is now an opaque typedef to facilitate splitting up
the enum into target-specific enums.
2020-01-03 10:53:22 -08:00
swift-ci
aa57f0c92b Merge remote-tracking branch 'origin/master' into master-next 2019-11-12 12:09:57 -08:00
Arnold Schwaighofer
4cba76309f IRGen: Add TypeExpansionContext to IRGen 2019-11-11 14:21:52 -08:00
Xi Ge
64c0680686 Merge remote-tracking branch 'apple/master' into master-next 2019-10-28 10:19:36 -07:00
Joe Groff
03c7919b4a SIL: Add fields to SILFunctionType for substituted function types.
https://forums.swift.org/t/improving-the-representation-of-polymorphic-interfaces-in-sil-with-substituted-function-types/29711

This prepares SIL to be able to more accurately preserve the calling convention of
polymorphic generic interfaces by letting the type system represent "substituted function types".
We add a couple of fields to SILFunctionType to support this:

- A substitution map, accessed by `getSubstitutions()`, which maps the generic signature
  of the function to its concrete implementation. This will allow, for instance, a protocol
  witness for a requirement of type `<Self: P> (Self, ...) -> ...` for a concrete conforming
  type `Foo` to express its type as `<Self: P> (Self, ...) -> ... for <Foo>`, preserving the relation
  to the protocol interface without relying on the pile of hacks that is the `witness_method`
  protocol.

- A bool for whether the generic signature of the function is "implied" by the substitutions.
  If true, the generic signature isn't really part of the calling convention of the function.
  This will allow closure types to distinguish a closure being passed to a generic function, like
  `<T, U> in (*T, *U) -> T for <Int, String>`, from the concrete type `(*Int, *String) -> Int`,
  which will make it easier for us to differentiate the representation of those as types, for
  instance by giving them different pointer authentication discriminators to harden arm64e
  code.

This patch is currently NFC, it just introduces the new APIs and takes a first pass at updating
code to use them. Much more work will need to be done once we start exercising these new
fields.

This does bifurcate some existing APIs:

- SILFunctionType now has two accessors to get its generic signature.
  `getSubstGenericSignature` gets the generic signature that is used to apply its
  substitution map, if any. `getInvocationGenericSignature` gets the generic signature
  used to invoke the function at apply sites. These differ if the generic signature is
  implied.
- SILParameterInfo and SILResultInfo values carry the unsubstituted types of the parameters
  and results of the function. They now have two APIs to get that type. `getInterfaceType`
  returns the unsubstituted type of the generic interface, and
  `getArgumentType`/`getReturnValueType` produce the substituted type that is used at
  apply sites.
2019-10-25 13:38:51 -07:00
Adrian Prantl
468b74bd70 Update Swift master-next for upstream llvm.org changes. 2019-10-21 13:31:31 -07:00
Shoaib Meenai
85b648b707 [swift] Adjust for LLVM r373425
Change TypeNodes.def to TypeNodes.inc.
2019-10-04 12:47:43 -07:00
Shoaib Meenai
a007f646fb [IRGen] Adjust for LLVM r373054
setAlignment now takes a MaybeAlign, so construct one where needed.
2019-09-30 12:04:32 -07:00
Alex Langford
0a74d1cdde Adjust for svn rL372558
The return type of DataLayout::getAlignment was modified to return an
llvm::Align instead of an unsigned. Adjust accordingly.
2019-09-23 13:48:04 -07:00
Alex Langford
986a036685 [ClangImporter][IRGen] Handle SVE builtin types
Clang r368413 introduced the SVE builtin types; update various switch
statements to handle them. This assumes that the types should not be
mapped into Swift, similar to the OpenCL types.

(cherry picked from commit 096e7ae96c)
2019-08-19 16:53:03 -07:00
Alex Langford
096e7ae96c [ClangImporter][IRGen] Handle SVE builtin types
Clang r368413 introduced the SVE builtin types; update various switch
statements to handle them. This assumes that the types should not be
mapped into Swift, similar to the OpenCL types.
2019-08-12 12:46:07 -07:00
Brent Royal-Gordon
fb20b503ba Merge branch 'master' into master-rebranch
# Conflicts:
#	lib/ClangImporter/ClangImporter.cpp
#	test/IRGen/builtins.swift
#	test/IRGen/enum.sil
#	tools/driver/autolink_extract_main.cpp
#	utils/build-presets.ini
2019-08-08 17:07:59 -07:00
Joe Groff
c0a9fef3cf Merge remote-tracking branch 'origin/master' into master-next 2019-08-05 10:38:17 -07:00
Joe Groff
f0e5e1911d IRGen: Access concrete type metadata by mangled name.
When we generate code that asks for complete metadata for a fully concrete specific type that
doesn't have trivial metadata access, like `(Int, String)` or `[String: [Any]]`,
generate a cache variable that points to a mangled name, and use a common accessor function
that turns that cache variable into a pointer to the instantiated metadata. This saves a bunch
of code size, and should have minimal runtime impact, since the demangling of any string only
has to happen once.

This mostly just works, though it exposed a couple of issues:

- Mangling a type ref including objc protocols didn't cause the objc protocol record to get
  instantiated. Fixed as part of this patch.
- The runtime type demangler doesn't correctly handle retroactive conformances. If there are
  multiple retroactive conformances in a process at runtime, then even though the mangled string
  refers to a specific conformance, the runtime still just picks one without listening to the
  mangler. This is left to fix later, rdar://problem/53828345.

There is some more follow-up work that we can do to further improve the gains:

- We could improve the runtime-provided entry points, adding versions that don't require size
  to be cached, and which can handle arbitrary metadata requests. This would allow for mangled
  names to also be used for incomplete metadata accesses and improve code size of some generic
  type accessors. However, we'd only be able to take advantage of the new entry points in
  OSes that ship a new runtime.
- We could choose to always symbolic reference all type references, which would generally reduce
  the size of mangled strings, as well as make runtime demangling more efficient, since it wouldn't
  need to hit the runtime caches. This would however require that we be able to handle symbolic
  references across files in the MetadataReader in order to avoid regressing remote mirror
  functionality.
2019-08-02 14:28:53 -07:00
swift-ci
cf177cc3eb Merge remote-tracking branch 'origin/master' into master-next 2019-03-06 07:49:31 -08:00
Arnold Schwaighofer
135e73ddab IRGen: Teach IRGen about calling noreturn C functions
rdar://46264442
SR-9313
2019-03-05 13:49:02 -08:00
Max Desiatov
37f8268ae7 Fix compatibility with upstream clang changes 2019-02-08 14:22:56 -08:00
Saleem Abdulrasool
e3da61b85f IRGen: adjust for SVN r352914 2019-02-04 10:14:31 -08:00
swift-ci
accd8ac8f3 Merge remote-tracking branch 'origin/master' into master-next 2018-11-30 00:30:45 -08:00
Slava Pestov
f8d28811bc IRGen: Relax an assertion
The result type mismatch comes up when we're calling a covariant
override of a class method resiliently as well.
2018-11-29 23:20:42 -05:00
Max Desiatov
de43c909c4 Fix compatibility with upstream clang changes 2018-11-10 11:13:41 +00:00
John McCall
3ea61ef4a0 Fix some IRGen bugs with coroutine lowering:
- The large-loadable-types pass was not rewriting function signatures
  correctly if only a yield type was rewritten.

- GenCall was not rewriting multiple yield types correctly.
2018-11-06 13:31:00 -05:00
Robert Widmann
57a5df1c49 Drop an unused variable from parameter explosion mapping 2018-10-06 17:52:58 -04:00
Jordan Rose
d412f4b4ba [IRGen] Adopt std::unique_ptr for IRGenDebugInfo (#19369) 2018-09-18 11:10:10 -07:00
Mike Ash
3e4a5a2d79 [Runtime][ABI] Have swift_willThrow take the error value in the return register.
rdar://problem/37578477
2018-08-22 15:04:49 -04:00
David Zarzycki
8c0c55539f [SIL] NFC: Rename misleading getSwiftRValueType() to getASTType()
Reference storage types are not RValues. Also, use more SILType helper
methods to avoid line wrap.
2018-05-04 08:14:38 -04:00
swift-ci
07db40fb71 Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-03-08 07:58:21 -08:00
Arnold Schwaighofer
f0bf9af158 IRGen: Fix assert
We only need a contextPtr if the function type requires a context

rdar://38241155
SR-7138
2018-03-08 05:59:00 -08:00
swift-ci
73f148384e Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-03-06 16:38:13 -08:00
Sho Ikeda
26d650292f [gardening] Use empty() over size() == 0 2018-03-05 14:43:13 +09:00
swift-ci
9e94284246 Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-02-26 14:00:10 -08:00
Vedant Kumar
f64d88591e [IRGen] Prevent mergeable traps from being created
PR #14729 made more calls to llvm.trap() non-mergeable. This follow-up
adds asserts to IRBuilder which make it harder to accidentally introduce
mergeable calls to llvm.trap() in the future.

The newly-added assertions exposed an issue in GenBuiltin while
compiling parts of the stdlib. This PR fixes the issue.

Suggested by Adrian Prantl!

rdar://32772768
2018-02-26 13:44:52 -08:00
swift-ci
2b9b846f42 Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-02-14 05:38:02 -08:00
Arnold Schwaighofer
882059674f IRGen: Support for trivial @noescape function types
- make @noescape function types trivial
- think_to_thick_function with @noescape result type
- Fix for getSwiftFunctionPointerCallee

Part of:
SR-5441
rdar://36116691
2018-02-13 04:19:59 -08:00
Bob Wilson
1b55b85e2b Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-01-09 16:12:10 -08:00
John McCall
3c54c0edfc IRGen and basic optimizer support for coroutines. 2018-01-09 11:35:09 -05:00
swift-ci
bda69c3eec Merge remote-tracking branch 'origin/master' into master-next 2017-12-20 15:09:46 -08:00
Arnold Schwaighofer
fb9696f427 IRGen: Fix mismatching sret attribute for indirect return values
We incorrectly lowered callsites when we had sil function return types
that involved both direct return types that we decide to lower
indirectly,  and indirect return types.

@convention(thin) () -> (@owned String, @owned String, @owned String, @out Any, @out Any)

(This should have been handled by the address lowering pass but isn't)

rdar://35874410
2017-12-19 18:58:53 -08:00
swift-ci
07902f91aa Merge remote-tracking branch 'origin/master' into master-next 2017-12-18 23:09:18 -08:00
John McCall
1f3f33e67d Clean up the internal APIs around dynamic allocas to structurally
discourage accidental use of them.  Relatedly, fix several bugs
where we were accidentally using dynamic allocas.
2017-12-19 00:29:43 -05:00
swift-ci
6d1f3c7eca Merge remote-tracking branch 'origin/master' into master-next 2017-12-12 17:29:39 -08:00
Thomas Roughton
f10ef1ab9a [runtime] Always use SwiftCC (#13311) 2017-12-12 17:11:38 -08:00
swift-ci
5540e26ee7 Merge remote-tracking branch 'origin/master' into master-next 2017-11-17 10:49:02 -08:00
Joe Shajrawi
62d823c56d Code size: Do not use a global state for isOutlined 2017-11-15 15:28:27 -08:00
swift-ci
09bc1805b7 Merge remote-tracking branch 'origin/master' into master-next 2017-10-27 11:49:41 -07:00
Saleem Abdulrasool
2e6e83b045 IRGen: avoid unnecessary coercion memory traffic
Attempt to avoid unnecessary traffic for the type coercion unless it is
really needed.
2017-10-26 18:40:05 -07:00
Saleem Abdulrasool
b53a422c59 IRGen: follow target specific ABI for FFI
When lowering the arguments for the FFI call on certain targets, LLVM
expects that the parameter be passed as a structure rather than the
extracted values.  Enhance the argument lowering for the call and the
function construction to ensure that the type can be flattened according
to the ABI for the target before attempting to explode it for the SIL
IRGen lowering.  This allows building for targets such as Linux ARM HF
and Linux ARM SF target with the HF floating point ABI.

Addresses SR-6142!
2017-10-26 09:42:21 -07:00
Saleem Abdulrasool
61a51e9870 IRGen: minor clean up to explosion handling (NFC)
Indicate that the type is const for the cast.  Use `Range` and a
for-loop rather than the explicit counters.  NFC.
2017-10-23 18:16:07 -07:00
swift-ci
bd13b59626 Merge remote-tracking branch 'origin/master' into master-next 2017-10-10 19:09:43 -07:00