Commit Graph

1087 Commits

Author SHA1 Message Date
Slava Pestov
cdcb8e4f0f AST: Lazier opaque type validation 2019-10-04 22:11:07 -04: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
Slava Pestov
f31bbf3a6e IRGen: Remove unnecessary cast from getOrCreateHelperFunction() 2019-09-10 16:14:45 -04:00
Mike Ash
f5e7ab866c Merge branch 'master' into master-next 2019-09-09 12:11:25 -04:00
swift-ci
f9a3c37ed6 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 19:03:47 -07:00
Slava Pestov
a0e160e215 AST: Refactor Decl::isWeakImported() API a little bit
First, remove the AvailabilityContext parameter; it was confusing because
we actually always want to use the deployment target here.

Then, split this method up into three methods:

- isAlwaysWeakImported(): simply checks for a @_weakLinked attribute, either
  on the declaration itself or one of its parent contexts.

- getAvailabilityForLinkage(): returns the OS version availability when
  this declaration was introduced, or if the declaration does not have
  explicit availability, check it's storage (if its an accessor), or its
  parent contexts.

- isWeakImported(ModuleDecl *fromModule): combines these two checks to
  determine if the declaration should be weak linked when referenced from
  the given module, or if it might be weak referenced from some module
  (if the module parameter is null).
2019-09-06 20:08:40 -04: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
2915d3a963 IRGen: Work around rdar://problem/53836960
On i386 Darwin, the linker appears to garble indirect symbolic references.
2019-08-02 14:28:58 -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
862b18da46 Merge remote-tracking branch 'origin/master' into master-next 2019-08-01 05:09:56 -07:00
Slava Pestov
d3f65e7b4b AST: Remove SubscriptDecl::isSettable() 2019-07-31 21:26:02 -04:00
swift-ci
9d1bd7fbdb Merge remote-tracking branch 'origin/master' into master-next 2019-06-26 21:49:21 -07:00
Saleem Abdulrasool
053425a6a1 IRGen: fix multithreaded COMDAT handling for PE/COFF
Correct the COMDAT handling for the type metadata emission.  In
particular, declarations should not be emitted with COMDATs.  The
pattern used in the compiler for the metadata emission is different than
the other structures.  In particular, `getAddrOfTypeMetadata` emits the
declaration for the type metadata symbol.  The definition for the type
metadata will be emitted via `defineTypeMetadata`.  This change adjusts
the IRGen to remove the COMDAT on the declaration permitting the
definition from `defineTypeMetadata` being emitted strongly.

This exposes a bug in the LLVM MC layer which is a separate change that
will enable this to function properly.
2019-06-25 20:12:43 -07:00
swift-ci
558ca0418c Merge remote-tracking branch 'origin/master' into master-next 2019-06-20 10:50:37 -07:00
Arnold Schwaighofer
fb08153de0 Fix dynamic replacement runtime when generating replacements from multiple object files
The sections with the replacements get merged and we need to consider all replacements.

SR-10947
rdar://51913012
2019-06-19 15:11:33 -07:00
Ben Langmuir
c42b732e26 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	lib/IRGen/IRGenModule.cpp
2019-06-18 09:35:57 -07:00
Arnold Schwaighofer
5d329464d6 Use thread private key to avoid weak linkage
We use one bit of the third reserved swift private tls key.

Also move the functionality into a separate static archive that is
always linked dependent on deployment target.
2019-06-17 15:03:45 -07:00
Arnold Schwaighofer
eb32194e97 Refactor to use RuntimeAvailability 2019-06-14 13:21:35 -07:00
Arnold Schwaighofer
5003c15079 stdlib: Add backward deployment versions for the
dynamic-replacement runtime functions.

The recent change of how we do dynamic replacements added 2 new runtime
functions. This patch adds those functions to the Compatibility50 static
archive.

This will allow backward deployment to a swift 5.0 runtime.

Patch by Erik Eckstein with a modification to call the standard
libraries implementation (marked as weak) when it is available.

This ensures we can change the implementation in the future and are not
ABI locked.

rdar://problem/51601233
2019-06-14 10:53:26 -07:00
swift-ci
ed38fe6251 Merge remote-tracking branch 'origin/master' into master-next 2019-06-04 10:09:06 -07:00
Joe Groff
4ed8de10f9 Revert "Revert "Use autolinking to pull in compatibility libraries."" 2019-06-03 20:10:51 -07:00
swift-ci
fd329da063 Merge remote-tracking branch 'origin/master' into master-next 2019-06-03 14:29:47 -07:00
Joe Groff
a7cc3a38cc Revert "Use autolinking to pull in compatibility libraries." 2019-06-03 14:18:39 -07:00
swift-ci
40c3c8caa5 Merge remote-tracking branch 'origin/master' into master-next 2019-06-03 08:30:09 -07:00
Joe Groff
a740ee55b2 Merge pull request #25148 from jckarter/runtime-compatibility-autolink
Use autolinking to pull in compatibility libraries.
2019-06-03 08:22:49 -07:00
Joe Groff
dffd1b27a1 Use autolinking to pull in compatibility libraries.
Many build systems that support Swift don't use swiftc to drive the linker. To make things
easier for these build systems, also use autolinking to pull in the needed compatibility
libraries. This is less ideal than letting the driver add it at link time, since individual
compile jobs don't know whether they're building an executable or not. Introduce a
`-disable-autolink-runtime-compatibility` flag, which build systems that do drive the linker
with swiftc can pass to avoid autolinking.

rdar://problem/50057445
2019-05-31 13:11:14 -07:00
swift-ci
d4508c5de0 Merge remote-tracking branch 'origin/master' into master-next 2019-05-30 20:09:36 -07:00
Erik Eckstein
4fb4435d12 IRGen: add an option to disable runtime calls for dynamic replacements.
With the option -Xllvm -basic-dynamic-replacement the runtime functions are not called (so it works with an old swift library).
But calling the original of a replaced function is not supported in this case.
2019-05-30 15:28:16 -07:00
Erik Eckstein
2ea531c3b3 IRGen/runtime: change the code generation for dynamically replaceable functions
Instead of a thunk insert the dispatch into the original function.
If the original function should be executed the prolog just jumps to the "real" code in the function. Otherwise the replacement function is called.
There is one little complication here: when the replacement function calls the original function, the original function should not dispatch to the replacement again.
To pass this information, we use a flag in thread local storage.
The setting and reading of the flag is done in two new runtime functions.

rdar://problem/51043781
2019-05-30 15:28:16 -07:00
Davide Italiano
433f6bf516 [GenDecl] XCOFF should be treated like COFF.
Fixes a build error:

/Users/local/swift/swift/lib/IRGen/GenDecl.cpp:1323:11: error: enumeration value 'XCOFF' not handled in switch [-Werror,-Wswitch]

All the other functions in this file group XCOFF and COFF together
so I guess this is a reasonable thing to do.
2019-05-23 17:18:50 -07:00
swift-ci
eeba41345d Merge remote-tracking branch 'origin/master' into master-next 2019-05-23 16:49:10 -07:00
Arnold Schwaighofer
b127aac1ce Merge pull request #24781 from aschwaighofer/fix_some_type_dynamic_replacement
Fix dynamic replacement of some type when used with associated types
2019-05-23 16:36:32 -07:00
swift-ci
5db4e8dba9 Merge remote-tracking branch 'origin/master' into master-next 2019-05-21 19:29:13 -07:00
Joe Groff
81c7f84ec9 IRGen: Work around JIT bug with GOT equivalents.
SR-10590 | rdar://problem/50968433 appears to be caused by an LLVM JIT bug where GOT-equivalent
globals get emitted with incorrect alignment. Not marking the GOT equivalent as unnamed_addr
(which prevents it from getting folded into the GOT, or other equivalent constants) appears
to work around the issue.
2019-05-21 14:17:07 -07:00
Arnold Schwaighofer
5c3a4d329b Fix dynamic replacement of some type when used with associated types
rdar://50638228
2019-05-18 10:34:52 -07:00
swift-ci
7714b5e862 Merge remote-tracking branch 'origin/master' into master-next 2019-05-03 23:09:28 -07:00
Joe Groff
22793b4567 Fixes for opaque return types on local functions.
- In Sema, don't traverse nested declarations while deducing the opaque return type. This would
  cause returns inside nested functions to clobber the return type of the outer function.
- In IRGen, walk the list of opaque return types we keep in the SourceFile already for type
  reconstruction, instead of trying to visit them ad-hoc as part of walking the AST, since
  IRGen doesn't normally walk the bodies of function decls directly.

Fixes rdar://problem/50459091
2019-05-03 16:53:21 -07:00
swift-ci
13c61ecb15 Merge remote-tracking branch 'origin/master' into master-next 2019-05-03 08:29:43 -07:00
Joe Groff
898665dee5 Merge pull request #24463 from jckarter/opaque-type-sync
NFC opaque type cleanups
2019-05-03 08:22:40 -07:00
Joe Groff
6c779bb487 Merge pull request #24445 from jckarter/opaque-type-remote
Debugger support for opaque types.
2019-05-03 08:18:59 -07:00
Joe Groff
72aa089130 NFC opaque type cleanups
- Add some assertions, and avoid an unnecessary asserting cast
- Replace a no-op access visitor with UNINTERESTING
2019-05-02 20:28:39 -07:00
swift-ci
32e725208d Merge remote-tracking branch 'origin/master' into master-next 2019-05-01 18:10:37 -07:00
Slava Pestov
3b6ec6c651 IRGen: Move some deployment target checks to LangOptions 2019-05-01 15:13:12 -04:00
Bob Wilson
33d9e52e72 Merge remote-tracking branch 'origin/master' into master-next 2019-05-01 09:33:08 -07:00
Joe Groff
4eb064dc21 IRGen: Emit opaque type descriptors for runtime lookup.
If -enable-anonymous-context-mangled-names is enabled, meaning that we assign names to
anonymous context descriptors for discovery by RemoteAST, then include opaque type descriptors
in the type metadata record table so that they can also be found at runtime by RemoteAST for
debugger support.
2019-04-29 18:11:01 -07:00
Doug Gregor
209e7fcd83 [IRGen] Emit lazy opaque type descriptors.
These were recorded but never emitted. Fixes rdar://problem/50258536.
2019-04-27 09:50:23 -07:00
swift-ci
9da051c4e6 Merge remote-tracking branch 'origin/master' into master-next 2019-04-24 08:09:16 -07:00
Arnold Schwaighofer
59ec94b4ed IRGen: Cleanup through use of IRGenFunction 2019-04-22 14:55:09 -07:00
Arnold Schwaighofer
6184bb6a34 IRGen: Traverse function type to find opaque archetypes 2019-04-22 13:03:10 -07:00