Commit Graph

7092 Commits

Author SHA1 Message Date
Joe Groff
381cf59cf3 Merge pull request #24978 from linux-on-ibm-z/interleave
[IRGen] Simplify constant occupied/spare bit interleaving
2019-05-24 18:56:44 -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
Michael Munday
253d5b5d18 [IRGen] Simplify constant occupied/spare bit interleaving
Add a new scatterBits function that is simpler and more generic
than the old interleaveSpareBits function. It is essentially a
constant version of the emitScatterBits function.
2019-05-22 16:19:01 +01:00
Joe Groff
3a1771c143 Merge pull request #24944 from jckarter/keypath-jit-workaround
IRGen: Work around JIT bug with GOT equivalents.
2019-05-21 19:16:34 -07:00
Joe Groff
33410bced6 Merge pull request #24857 from linux-on-ibm-z/gather-scatter
[IRGen] Remove SetBitEnumerator from ClusteredBitVector
2019-05-21 16:16:57 -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
Joe Groff
b896361d88 IRGen: Map type into context before asking for class layout.
Asking for the layout of the interface type apparently gives the wrong answer,
causing key paths to access stored properties of generic classes using the wrong
strategy.

Fixes SR-10167 | rdar://problem/49230751.
2019-05-20 16:08:38 -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
Michael Munday
d3262ec10d [IRGen] Remove SetBitEnumerator from ClusteredBitVector
The change replaces 'set bit enumeration' with arithmetic
and bitwise operations. For example, the formula
'(((x & -x) + x) & x) ^ x' can be used to find the rightmost
contiguous bit mask. This is essentially the operation that
SetBitEnumerator.findNext() performed.

Removing this functionality reduces the complexity of the
ClusteredBitVector (a.k.a. SpareBitVector) implementation and,
more importantly, API which will make it easier to modify
the implementation of spare bit masks going forward. My end
goal being to make spare bit operations work more reliably on
big endian systems.

Side note:

This change modifies the emit gather/scatter functions so that
they work with an APInt, rather than a SpareBitVector, which
makes these functions a bit more generic. These functions emit
instructions that are essentially equivalent to the parallel bit
extract/deposit (PEXT and PDEP) instructions in BMI2 on x86_64
(although we don't emit those directly currently). They also map
well to bitwise manipulation instructions on other platforms (e.g.
RISBG on IBM Z). So we might find uses for them outside spare bit
manipulation in the future.
2019-05-17 11:55:06 +01:00
Joe Groff
d22a405e38 Merge pull request #24822 from jckarter/opaque-type-runtime-weak-link
IRGen: Weak-link opaque type entry points.
2019-05-16 07:06:36 -07:00
Joe Groff
2ade303387 IRGen: Weak-link opaque type entry points.
When backward deploying to an OS that may not have these entry points, weak-link them so that they
can be used conditionally in availability contexts that check for them.

rdar://problem/50731151
2019-05-15 20:40:54 -07:00
Slava Pestov
22cea6cf54 IRGen: Remove IRBuilder::StableIP 2019-05-13 23:12:48 -04:00
Slava Pestov
36e46c054d IRGen: Fix DynamicSelfType metadata recovery in @objc convenience initializers
An @objc convenience initializer can replace 'self'. Since IRGen
has no way to tell what the new 'self' value is from looking at
SIL, it always refers back to the original 'self' argument when
recovering DynamicSelfType metadata. This could cause a crash
if the metadata was used after the 'self' value had been
replaced.

To fix the crash, always insert the metadata recovery into the
entry block, where the 'self' value should be valid (even if
uninitialized, the 'isa' pointer should be correct).

Fixes <rdar://problem/50594689>.
2019-05-13 23:11:11 -04:00
Joe Groff
f96602063c Merge pull request #23884 from linux-on-ibm-z/s390x-gentype-fix
IRGen: fix get/store enum tag functions for big-endian platforms
2019-05-11 18:09:37 +08:00
Slava Pestov
12469f5a9b IRGen: Always emit class stubs for classes with resilient ancestry
This logic is no longer guarded by a flag. Sema will still emit certain
diagnostics if the flag is not specified though.

Progress on <rdar://problem/49090631>.
2019-05-10 21:26:10 -04:00
Slava Pestov
075b918e58 Merge pull request #24674 from linux-on-ibm-z/payload-schema-deadcode
[IRGen]: Remove unused explosion schema from enum payload schema
2019-05-10 20:05:29 -04:00
Michael Munday
25a075cbb6 [IRGen] Remove unused explosion schema from enum payload schema
At some point it might be useful to be able to use an appropriate
explosion schema to explode payloads but currently the code that
handles this is unused. There are lots of different ways we might
add this functionality in the future and it isn't clear that the
existing code will be the best way to use explosion schemas in the
future.

For now remove this dead code so that its presence doesn't obscure
the code that is actually in use.
2019-05-10 12:15:11 +01:00
Michael Munday
6bb79cafd9 [IRGen] Remove unused static applyFixedSpareBitsMask function
The function was only used in the non-static function of the same
name. Inline it into that function and remove it.
2019-05-08 13:42:53 +01:00
Arnold Schwaighofer
510764a834 Merge pull request #24517 from aschwaighofer/dont_emit_opaque_type_descriptor_twice
IRGen: Don't emit opaque type descriptors twice
2019-05-07 10:37:26 -07:00
Arnold Schwaighofer
da999f0fd7 Use noteUseOfOpaqueTypeDescriptor instead of introducing and using markOpaqueTypeDescriptorEmitted 2019-05-06 12:08:04 -07:00
Arnold Schwaighofer
fc8ff70be7 IRGen: Don't emit opaque type descriptors twice
rdar://50500620
2019-05-06 09:32:29 -07:00
Saleem Abdulrasool
218b37e1bb build: rename LLVM_COMPONENT_DEPENDS
This is not a target dependency but a target link.  Name the parameter
to be less misleading.  This also makes the name identical to the LLVM
parameter.
2019-05-04 19:58:28 -07:00
Joe Groff
16b6aa5457 Merge pull request #24494 from jckarter/opaque-local-return
Fixes for opaque return types on local functions.
2019-05-03 23:02:12 -07:00
swift-ci
11e36fdbbb Merge pull request #24467 from DougGregor/lazy-opaque-info-cleanup 2019-05-03 21:56:06 -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
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
Doug Gregor
7228864f6b [IRGen] Remove unused field from LazyOpaqueInfo
Addresses rdar://problem/50376440.
2019-05-02 21:19:42 -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
Joe Groff
a6b5a41a32 IRGen: Generate anonymous contexts for properties with opaque return types.
They aren't normally decl contexts, but if one has an opaque type, we want to be able to record
the property as a context so that we can reconstruct it in RemoteAST.
2019-05-02 17:28:08 -07:00
swift-ci
f8f7139819 Merge pull request #24416 from adrian-prantl/50349713 2019-05-01 18:46:01 -07:00
Joe Groff
fc8be62895 RemoteAST: Add a request to get the underlying type from an opaque type descriptor. 2019-05-01 15:42:57 -07:00
Adrian Prantl
e63caa4d45 Debug Info: Mark variables without source location as artificial.
rdar://problem/50349713
2019-05-01 15:18:15 -07:00
Slava Pestov
3b6ec6c651 IRGen: Move some deployment target checks to LangOptions 2019-05-01 15:13:12 -04:00
Joe Groff
7f76ed6d62 IRGen: Render opaque types like other archetypes in debug info. 2019-04-30 13:44:59 -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
Arnold Schwaighofer
d044696b30 Merge pull request #24293 from aschwaighofer/compiler_fix_initEnumMetadataSingleCase
IRGen: Initialize single case enum extrainhabitant value witness in generated code
2019-04-29 10:00:04 -07:00
swift-ci
18f027af3a Merge pull request #24337 from DougGregor/irgen-emit-lazy-opaque-descriptors 2019-04-27 11:02:14 -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
Saleem Abdulrasool
83b290438c Windows: bridge BOOL to Bool
This allows the conversion of the Windows `BOOL` type to be converted to
`Bool` implicitly.  The implicit bridging allows for a more ergonomic
use of the native Windows APIs in Swift.

Due to the ambiguity between the Objective C `BOOL` and the Windows
`BOOL`, we must manually map the `BOOL` type to the appropriate type.
This required lifting the mapping entry for `ObjCBool` from the mapped
types XMACRO definition into the inline definition in the importer.

Take the opportunity to simplify the mapping code.

Adjust the standard library usage of the `BOOL` type which is now
eclipsed by the new `WindowsBool` type, preferring to use `Bool`
whenever possible.

Thanks to Jordan Rose for the suggestion to do this and a couple of
hints along the way.
2019-04-25 17:52:08 -07:00
Arnold Schwaighofer
e2d3f533d6 IRGen: Intialize single case enum extrainhabitant value witness in generated code
Older Swift runtimes miss this initialization in the swift_initEnumMetadataSingleCase runtime call.

rdar://49786768
2019-04-25 14:19:56 -07:00
Saleem Abdulrasool
bad5b585ca Merge pull request #24263 from compnerd/weakness
IRGen: do not use `WeakImport` on PE/COFF
2019-04-25 07:46:33 -07:00
swift-ci
d24bc38797 Merge pull request #23701 from DougGregor/property-delegates-as-custom-attributes 2019-04-24 22:51:18 -07:00
Saleem Abdulrasool
68ca11bb2a IRGen: do not use WeakImport on PE/COFF
PE/COFF does not provide weak import semantics.  Fallback to strong
import semantics on PE/COFF.
2019-04-24 20:55:42 -07:00
Bob Wilson
f33b990446 Merge pull request #24242 from bob-wilson/rdar50110036
References to _swift_FORCE_LOAD* symbols should be weak
2019-04-24 17:05:17 -07:00
Bob Wilson
dd94a9f90f References to _swift_FORCE_LOAD* symbols should be weak
When Swift always copied the overlay dylibs into app bundles, it was OK
for these symbol references to be non-weak, but with the overlays now
part of the OS on Apple platforms, we need to handle backward deployment
scenarios where a new overlay does not exist on an old OS version.
A weak reference will serve to pull in the overlay dylib if it exists,
without causing a fatal error if it does not. rdar://problem/50110036
2019-04-24 09:45:07 -07:00
Arnold Schwaighofer
43a7b44577 Merge pull request #24201 from aschwaighofer/opaque_result_types_dyn_replacement_and_specialization
Opaque result types: dynamic replacement
2019-04-24 07:58:50 -07:00
Nathan Lanza
f837a9eeef Fix bug where inlined scopes where being inlined twice for codeview
A workaround in codeview debuginfo generation was to declare a condfail
instruction as inlined to avoid using 0 as an artificial line location.

However, this was done without accounting for scopes that were already
legitimately inlined. So we'd end up with a condfail inlined from
function B into function A and then the IRGen for the condfail was
being given a debugloc claiming to have been inlined again. This was
causing a sitaution where we'd have debug info forfunctionA owning an
instruction which claimed it was owned by a different function.

Fix this by first checking if the `LastScope` was already inlined and,
if so, just used that scope instead.
2019-04-23 12:40:48 -07:00
Erik Eckstein
2e01b0edeb SIL: add assign_by_delegate instruction
Used for property delegates.
2019-04-23 11:32:28 -07:00
Arnold Schwaighofer
59ec94b4ed IRGen: Cleanup through use of IRGenFunction 2019-04-22 14:55:09 -07:00