Commit Graph

576 Commits

Author SHA1 Message Date
Nate Chandler
1a106d329f [NFC] Tweaked name of NecessaryBindings factory method. 2020-10-06 11:55:25 -07:00
Nate Chandler
15d90d8f5b [IRGen] Pull async polymorphic params from explosion.
Previously, the polymorphic arguments were being discarded.  Here, that
situation is improved by pulling the polymorphic arguments out of the
explosion when having the polymorphic parameters via the
NecessaryBindings instance.  In order to eanble that, an overload of
NecessaryBindings::save is added which takes an explosion and asserts
that the polymorphic parameter pulled from the explosion matches with
the polymorphic parameter in the NecessaryBindings instance.
2020-10-06 11:55:10 -07:00
Nate Chandler
d2fc2c1e35 [IRGen] Silenced unused variable warning. 2020-10-06 11:54:38 -07:00
swift_jenkins
eeb14d44d3 Merge remote-tracking branch 'origin/main' into next 2020-10-06 08:03:33 -07:00
Nate Chandler
ee88152d6b [Concurrency] First steps towards async CC.
Here, the following is implemented:
- Construction of SwiftContext struct with the fields needed for calling
  functions.
- Allocating and deallocating these swift context via runtime calls
  before calling async functions and after returning from them.
- Storing arguments (including bindings and the self parameter but not
  including protocol fields for witness methods) and returns (both
  direct and indirect).
- Calling async functions.

Additional things that still need to be done:
- protocol extension methods
- protocol witness methods
- storing yields
- partial applies
2020-10-05 20:43:51 -07:00
Michael Forster
d222447142 Remove calls to deprecated default-false VectorType::get.
This function was removed in https://reviews.llvm.org/D84212,
which makes the master-next build fail.
2020-08-13 12:05:16 +02:00
Arnold Schwaighofer
0dd2e0da81 Adjust to addition of ABIArgInfo::IndirectAliased
rdar://66694325
2020-08-07 13:55:19 -07:00
David Zarzycki
79df342146 Do not hardcode SVE type list 2020-06-15 06:00:20 -04:00
Karoy Lorentey
57ea964f2c Merge commit '3eb82c183662945687f48e11c09828f551b34858' into master-next
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:58:37 -07:00
David Zarzycki
7525b63412 Unbreak after clang added BFloat16 builtin
In apple/llvm-project 9e7b7cbbbdb59d53136c0480f17cfe6ecef94163
(llvm/llvm-project ecd682bbf5e69e8690b7e3634258f05ae0a70448), BFloat16
was added to the clang builtins.
2020-06-06 07:27:51 -04:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
swift_jenkins
ee07f00381 Merge remote-tracking branch 'origin/master' into master-next 2020-05-27 02:39:04 -07:00
David Zarzycki
eab7cb7d38 [IRGen] NFC: Clean up Alignment type
1) Shrink from 4 bytes to 1 byte.
2) Assert that alignments are power-of-two at run time.
3) Assert that alignments are power-of-two at compile time when possible.
4) Eliminate "isZero"/"no alignment" from the type. Use llvm::Optional.
2020-05-26 10:36:33 -04:00
Arnold Schwaighofer
2b2f7dcd2f Adjust to AllocaInst MaybeAlign -> Align api change 2020-05-20 07:45:43 -07:00
Arnold Schwaighofer
eab0fe2ff7 IRGen: Adjust to added Matrix type ignore for now 2020-05-12 08:22:31 -07:00
swift_jenkins
c60a485196 Merge remote-tracking branch 'origin/master' into master-next 2020-05-06 12:35:16 -07:00
Arnold Schwaighofer
147144baa6 SIL: Thread type expansion context through to function convention apis
This became necessary after recent function type changes that keep
substituted generic function types abstract even after substitution to
correctly handle automatic opaque result type substitution.

Instead of performing the opaque result type substitution as part of
substituting the generic args the underlying type will now be reified as
part of looking at the parameter/return types which happens as part of
the function convention apis.

rdar://62560867
2020-05-04 13:53:30 -07:00
swift_jenkins
27826c53e3 Merge remote-tracking branch 'origin/master' into master-next 2020-04-29 12:47:24 -07:00
Michael Forster
1e1aa4635a Inline deprecated CallBase::getCalledValue
This function has already been removed on upstream LLVM. Inlining it
here fixes a compile issue on `master-next`.
2020-04-29 18:04:42 +02:00
swift_jenkins
d079c2ba99 Merge remote-tracking branch 'origin/master' into master-next 2020-04-28 05:19:09 -07:00
Erik Eckstein
e196932f67 Remove includes to llvm's CallSite.h
Fixes a master-next compile problem
2020-04-28 11:58:38 +02:00
Michael Forster
bcf0afd57a Ignore ExtInt for C interop and IRGen
This feature was introduced here:
61ba1481e2
2020-04-20 11:53:06 +02:00
Robert Widmann
85fdc7a555 Merge pull request #31080 from CodaFi/why-I-R-ta
Give IRGenModule Ownership of its LLVMContext
2020-04-17 10:32:46 -07:00
Michael Forster
8d1d9f1eb5 Remove calls to deprecated IRBuilder APIs
These APIs have been removed in upstream LLVM, breaking master-next.
2020-04-17 09:32:03 +02:00
Robert Widmann
40d9cd8d3f [NFC] Give IRGenModule Exclusive Ownership of an LLVMContext Object 2020-04-16 11:57:44 -07:00
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