The new function swift_getCanonicalSpecializedMetadata takes a metadata
request, a prespecialized non-canonical metadata, and a cache as its
arguments. The idea of the function is either to bless the provided
prespecialized metadata as canonical if there is not currently a
canonical metadata record for the type it describes or else to return
the actual canonical metadata.
When called, the metadata cache checks for a preexisting entry for this
metadata. If none is found, the passed-in prespecialized metadata is
added to the cache. Otherwise, the metadata record found in the cache
is returned.
rdar://problem/56995359
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
The new function swift_compareProtocolConformanceDescriptors calls
through to the preexisting code in MetadataCacheKey which has been
extracted out from MetadataCacheKey::compareWitnessTables into a new
public static function
MetadataCacheKey::compareProtocolConformanceDescriptors.
The new function's availability is "future" for now.
The new function `swift_compareTypeContextDescriptors` is equivalent to
a call through to swift::equalContexts. The implementation it the same
as that of swift::equalContexts with the following removals:
- Handling of context descriptors of kind other outside of
ContextDescriptorKind::Type_First...ContextDescriptorKind::Type_Last.
Because the arguments are both TypeContextDescriptors, the kinds are
known to fall within that range.
- Casting to TypeContextDescriptor. The arguments are already of that
type.
For now, the new function has "future" availability.
This commit adds -lto flag for driver to enable LTO at LLVM level.
When -lto=llvm given, compiler emits LLVM bitcode file instead of object
file and perform thin LTO using libLTO.dylib plugin.
When -lto=llvm-full given, perform full LTO instead of thin LTO.
Clang provides options to override that default value.
These options are accessible via the -Xcc flag.
Some Swift functions explicitly disable the frame pointer.
The clang options will not override those.
A lot of attributes are essentially default target configuration, and we should only differ when there's a good reason to.
For the attributes we were already setting:
- the ptrauth and target CPU/feature attributes are taken care of by Clang
- I've updated the optsize/minsize attributes to the apparent intent
- I've left the frame-pointer override in place for now
Fixes rdar://63289339, which was caused by Swift's ptrauth IR attributes getting out of sync with Clang's.
This simplifies fixing the master-next build. Upstream LLVM already
has a copy of this function, so on master-next we only need to delete
the Swift copy, reducing the potential for merge conflicts.
swift::GeneratedModule encapsulates an llvm::Module, llvm::LLVMContext
pair that must live and die together. It has convenient accessors for
projecting the module and context components. The meat of this type is
the two conversion functions, which transfer ownership of either the
module component to the caller or the module and context to ORCJIT.
This is because ORC enforces an ownership contract that is distinct from
LLVM's rather wild ownership story for modules and their associated
contexts. See http://llvm.org/docs/ORCv2.html#how-to-use-threadsafemodule-and-threadsafecontext
This adds code that can be used to build recursive type layouts. And
code that generates value witness IR based on the recursive type
layouts.
Value witnesses generated based on type layouts will only refer to
archetypes when computing fields offsets for frozen generic types (vs
instantiated type medata).
rdar://51988441
Regardless of any flags, the stdlib will have its generic metadata
prespecialized.
Temporarily reintroduced the flag to enable the feature flag while
preserving the flag to disable it and changed the default back to off
for the moment.
SIL differentiability witnesses are a new top-level SIL construct mapping
an "original" SIL function and derivative configuration to derivative SIL
functions.
This patch adds `SILDifferentiabilityWitness` IRGen.
`SILDifferentiabilityWitness` has a fixed `{ i8*, i8* }` layout:
JVP and VJP derivative function pointers.
Resolves TF-1146.
Temporarily disable metadata prespecialization on platforms other than
MacOS, iOS, tvOS, watchOS, or Linux. At the moment, tests are failing
on Windows with linker errors such as
demangleToMetadata-558ea9.o : error LNK2001: unresolved external symbol $ss5Int64VN
demangleToMetadata-558ea9.o : error LNK2001: unresolved external symbol $sSSSHsWP
Once the issue leading to those linker errors has been resolved, the
feature will be enabled on Windows.
This was being done at an odd point in the frontend presumably because by that point the private discriminator had been fully computed. Instead, push the conditions for generating the prefix data down to debug info generation and stop mutating IRGenOptions::DebugFlag in the frontend.
ELF's lack of linker directives is worked around by a custom section
(`.swift1_autolink_entries`). This is metadata that is not intended to
be emitted into the linked binary. A previous change introduced the use
of a module (global) assembly gadget to discard the section. However,
this interacts poorly with ASAN which would instrument the section,
resulting in a strong reference. This reference would persist to a
discarded symbol. lld would object to this. Blacklist the symbol to
ensure that ASAN + autolinking can co-exist.
Compatibility with earlier swift runtimes would require modifying the
runtime compatibility libraries to adjust the behavior of
checkMetadataState by way of typeForMangledNode or even
typeForMangledName. For now, simply require that a version of swift
whose runtime knows about prespecialized metadata is being targeted.
autolink-extract is needed on ELF (and windows-cygnus). However, WASM
also has gone down this path and did not actually indicate that it
needed the autolink extract handling. Extract the handling check into a
variable which helps readability.
WASM currently is treated identically to the ELF paths. Collocate the
types to make it easier to ensure that all the paths are correctly
handling the emission. This adds the missed case for the module hash.
use getTypeByMangledName when abstract metadata state is requested
This can significantly reduce the code size of apps constructing deeply
nested types with conditional conformances.
Requires a new runtime.
rdar://57157619
The TAPI_SWIFT_ABI_VERSION macro was never updated in sync with
IRGen::swiftVersion, so just expose that value through
irgen::getSwiftABIVersion() and use it in TBDGen.
Fixes rdar://55643763
On targets which support COMDAT (PE/COFF, ELF), use that to relax the
constraints on the emission of `-force-autolink-symbol` so that it is
possible to use that with `-incremental`.
Mark the section .swift1_autolink_entries as SHF_EXCLUDE
so the section will get dropped by the linker after linking the final
binary.
This section is used to save the flags needed for auto link and there
is no reason it should stay in the final linked binary.Mark the
section .swift1_autolink_entries as SHF_EXCLUDE
so the section will get dropped by the linker after linking the final
binary.
This section is used to save the flags needed for auto link and there
is no reason it should stay in the final linked binary.
This solves issue SR-11247