Commit Graph

3719 Commits

Author SHA1 Message Date
swift-ci
427c902a71 Merge remote-tracking branch 'origin/master' into master-next 2019-08-23 08:50:18 -07:00
Davide Italiano
b163c3ead0 [SISLLocation] Remove NoneKind, it's been unused for a while. 2019-08-22 14:08:40 -07:00
Alex Langford
2e72610509 Replace last uses of llvm::index_sequence_{,for} 2019-08-15 14:07:26 -07:00
Alex Langford
0cbc931bb7 Replace use of LLVM_IS_FINAL with std::is_final
LLVM svn r368910 got rid of LLVM_IS_FINAL with std::is_final. Adjust
accordingly.
2019-08-14 18:35:56 -07:00
Erik Eckstein
fdcb46eacd SIL: Utilities for calculating and verifying memory lifetimes.
In analogy to the ownership verifier, the MemoryLifetimeVerifier checks the lifetime of memory locations.
It's based on MemoryLocations and MemoryDataflow, which are general utilities for analysing memory locations and calculating the lifetime of locations.

Memory locations are limited to addresses which are guaranteed to be not aliased, like @in/inout parameters or alloc_stack.
2019-08-13 09:50:30 +02:00
Erik Eckstein
32c0feb577 SIL: add a [dynamic_lifetime] flag to alloc_stack and alloc_box
This flag is set by DefinitInitialization if the lifetime of the stored value is controlled dynamically.
If the flag is set, it's not (easily) possibly to statically calculate the lifetime of the stored value.
2019-08-13 09:29:05 +02:00
Erik Eckstein
2ca7807b48 SIL: fix ApplySite.isArgumentOperand()
isArgumentOperand should return false for implicit archetype operands.
2019-08-13 09:26:13 +02:00
Michael Gottesman
93ed95847a [ownership] When deserializing a SILFunction, match the ownership of the deserialized function.
Ownership is truly a property not of a declaration, but of a function body. So
it makes sense to just match what we deserialize.

This also helps us to avoid mismatches if we lower ownership from a function,
delete it, and then relink it.

I also used this as an opportunity to clean up where we set that flag in
deserialization to only happen in one place for both declarations/definitions.
2019-08-11 15:05:54 -07:00
Slava Pestov
9dd835c71b Sema: Replace the finalizeDecl() mechanism with ClassDecl::getEmittedMembers()
The only thing remaining in finalizeDecl() is synthesis of
certain class members. Let's turn that into a request.
2019-08-09 19:08:47 -04:00
Joe Groff
77b012af1d SIL: Add an [exact_self_class] function attribute.
This indicates that the "self" argument to the current function is always dynamically of the exact
static base class type, allowing metadata accesses in IRGen to use the local self metadata to answer
metadata requests for the class type. Set this attribute on allocating entry points of designated
inits, which is one of the most common places where we emit redundant metadata accesses.
2019-08-08 14:03:07 -07:00
Joe Groff
51f77aae55 Merge pull request #26475 from jckarter/generic-metadata-accessor-shim
IRGen: Factor out calling convention shuffling in metadata accessors, and remove frame pointers.
2019-08-07 16:23:58 -07:00
Joe Groff
3e2965f452 IRGen: Omit frame pointers from metadata accessors. 2019-08-07 14:16:41 -07:00
adrian-prantl
03f15d83af Merge pull request #26517 from adrian-prantl/warnings
Fix a few unused variable warnings.
2019-08-06 16:44:26 -07:00
Adrian Prantl
c63a3d2564 Fix a few unused variable warnings. 2019-08-06 13:05:44 -07:00
Michael Gottesman
037f6c1606 Merge pull request #26501 from gottesmm/pr-48526a73d520afbaaeda3525ce0a6f87a84fb1dc
[gardening] Remove code needed for Ownership SIL bringup.
2019-08-05 23:43:40 -07:00
Michael Gottesman
d5b50e90e2 [gardening] Remove code needed for Ownership SIL bringup.
Now we just always mark functions as having or not having ownership. So we know
when parsing/deserializing what state we are in already. There are also
assertions in SILBuilder around most of the instructions that can exist in only
a single mode, meaning even the error was sort of redundant.
2019-08-05 17:34:59 -07:00
Michael Gottesman
9c58e4b0a3 [patternmatch] Add InstructionOperand_match to support for matching against instructions with misc number of operands.
NOTE:

1. To test this I changed UnaryOp_match to use this under the hood.

2. These types of m_##ID##Inst matchers now will only accept compound types and
I added a static assert to verify that this mistake doesn't happen. We
previously had matchers that would take an int or the like to match tuple
extract patterns. I converted those to use TupleExtractOperation that also
properly handles destructures.
2019-08-05 17:26:02 -07:00
John McCall
765d3383f8 Merge pull request #26047 from pschuh/cpp-2
Add importing cxx function decls and the basic requisite AbstractionPattern support.
2019-08-01 13:30:59 -04:00
Jordan Rose
844ae38722 Remove some Swift STLExtras that LLVM now provides (#26443)
No functionality change.
2019-07-31 18:34:52 -07:00
Slava Pestov
37f0d6a613 Sema: Refactor away maybeAddAccessorsToStorage()
This centralizes the decision to add or not to add accessors in one place.
2019-07-31 14:54:57 -04:00
Parker Schuh
4a5dae5ed4 Add importing cxx function decls and the basic requisite AbstractionPattern support. 2019-07-30 15:46:47 -07:00
Slava Pestov
0026493f4d SIL: VTable visitor now visits accessors as part of their storage
This is NFC for now, but soon accessors will not no longer appear
when iterating over NominalTypeDecl::getMembers().
2019-07-30 15:14:33 -04:00
Slava Pestov
28f1bb99b3 TBD: Use SILWitnessVisitor instead of baking in knowledge of witness table layout 2019-07-24 13:11:20 -04:00
Slava Pestov
83c90b6b2a AST: Turn NominalTypeDecl::getStoredProperties() into a request
This improves on the previous situation:

- The request ensures that the backing storage for lazy properties
  and property wrappers gets synthesized first; previously it was
  only somewhat guaranteed by callers.

- Instead of returning a range this just returns an ArrayRef,
  which simplifies clients.

- Indexing into the ArrayRef is O(1), which addresses some FIXMEs
  in the SIL optimizer.
2019-07-16 16:38:38 -04:00
Erik Eckstein
237a3ef77f SIL: Extend cond_fail by a second operand, which is a static string literal, indicating the failure reason. 2019-07-16 12:31:10 +02:00
Brent Royal-Gordon
d5a2912a26 Revert "Better runtime failure messages (not yet enabled by default)" 2019-07-15 13:42:40 -07:00
Erik Eckstein
e2d313ef68 SIL: Extend cond_fail by a second operand, which is a static string literal, indicating the failure reason. 2019-07-12 14:03:13 +02:00
Michael Gottesman
4cb03c2784 [diagnose-unreachable] Constant fold simple switch_enum_addr to eliminate more unreachable code.
This patch comes out of my reading some generic code using .none in transparent
functions to conditionally compile out code at -Onone. Sadly, before this the
dead code in question wouldn't be compiled out unless the protocol was
constrained to be a class protocol.

I added a test that validates that this conditional compilation property can be
relied on in -Onone code in both cases.
2019-07-08 11:38:53 -07:00
Michael Gottesman
0bdaa524a6 Merge pull request #25918 from gottesmm/pr-30c3bd84dd6a3d388dda37c71df157036987edf2
[sil] Add dumpers for ResilienceExpansion/TypeLowering.
2019-07-02 10:32:52 -07:00
Michael Gottesman
07293f6359 [sil] Add support to SILType for looking up its mangled name.
This can be really useful when using conditional break points in
TypeLowering.

NOTE: Certain SILTypes do not have manglings and this will assert! We should
change the mangling infrastructure to just return Optional<None> or false
instead.
2019-07-01 13:41:54 -07:00
Michael Gottesman
6c6bfc2b5c [sil] Add dumpers for ResilienceExpansion/TypeLowering.
This makes it much easier to debug TypeLowering since one can find when
recursive properties do not match up/etc.
2019-07-01 13:40:40 -07:00
Slava Pestov
06ecb8d5c7 SIL: Remove CaptureKind::None and clean up some other capture-related logic 2019-06-27 20:59:22 -04:00
Michael Gottesman
5d9675392e [cast-opt] Improve handling of arguments when optimizing Swift -> ObjC bridging casts.
Specifically:

1. I removed an extra defensive copy that we put in place some time ago that
isn't really warranted. We know that we have an @owned value, so can safely just
pass the value as a @guaranteed parameter. This also eliminates an ownership
error that would occur due to my not having updated this code for ownership in
tree.

2. I also ensured that if we are performing a loadable address bridging cast ->
value bridging cast that we store the loadable value back into memory after we
perform the cast. Otherwise, it appears to leak to the ownership verifier.

I also centralized the non-ownership tests for this into one place
(const_fold_objc_bridge.sil => constant_propagation_objc.sil).
2019-06-23 13:17:10 -07:00
Saleem Abdulrasool
38995f5d80 Merge pull request #25070 from moatom/fix-include-guard
Fix include guards
2019-06-20 17:26:08 -07:00
Davide Italiano
af541470f5 Merge pull request #25472 from dcci/silbuilder-inherit
[SILInliner] Inherit SILBuilderContext when creating a new one.
2019-06-14 18:24:25 -07:00
Davide Italiano
36b917b048 [SILInliner] Inherit SILBuilderContext when creating a new one.
Addresses Michael's feedback on my last commit.
2019-06-14 10:49:02 -07:00
Michael Gottesman
aef60e64d6 [sil] Add an overload to SILDebugScope::dump that just takes a SILModule as an argument.
We do not in general want SIL code to root around in the ASTContext. Better to
just have a helper that knows how to fish it out.
2019-06-12 16:35:08 -07:00
Slava Pestov
77a6c9ebe2 Merge pull request #25191 from slavapestov/vtable-thunk-cleanup
VTable thunk cleanup
2019-06-10 17:02:54 -07:00
Michael Gottesman
cf0405c7f1 [clf] Simplify the double diamond lifetime extension for escaping swift funcs -> noescape blocks.
Specifically, when we optimize conversions such as:

  Optional<@escaping () -> ()>

  ->

  Optional<@noescape () -> ()>

  ->

  Optional<@noescape @convention(block) () -> ()>

previously we were lifetime extending over the @noescape lifetime barrier by
making a copy and then putting a mark_dependence from the copy onto the original
value. This was just a quick way to tell the ownership verifier that the copy
was tied to the other value and thus should not be eliminated. The correctness
of the actual lifetime extension comes from the optimizer being conservative
around rr insts.

This commit instead changes our optimization to borrow the copied optional
value, extract the payload, and use that instead.
2019-06-09 22:04:32 -07:00
Slava Pestov
f681cbe264 SIL: Remove SILVTable::Entry::Linkage
This field would store the linkage of the original method, if it was
distinct from the linkage of a vtable thunk. It is no longer used.
2019-06-09 15:54:05 -07:00
Vedant Kumar
569c8afc54 [Profiler] Separate profiler instances for property inits and constructors (#25247)
Assign separate SILProfiler instances to stored property initializers
and constructors.

Starting with rdar://39460313, coverage reporting for these constructs
was bundled up into a single SILProfiler uniqued by the NominalTypeDecl.
There are two problems with doing this.

First, the shared SILProfiler is given a fake name that can't be
demangled. That breaks Xcode's reports.  Second, the relationship
between SILProfiler and SILFunction is supposed to be 1:1. Having a
shared SILProfiler muddies things a bit and requires extra bookkeeping.

rdar://47467864
2019-06-05 10:38:10 -07:00
moatom
2e95a0d265 Fix include guards 2019-06-02 12:10:43 +09:00
Saleem Abdulrasool
731c31f9a5 MSVC: litter the code with llvm_unreachable (NFC)
Add `llvm_unreachable` to mark covered switches which MSVC does not
analyze correctly and believes that there exists a path through the
function without a return value.
2019-06-01 19:02:46 -07:00
Slava Pestov
a31248997c SILGen: Correctly emit vtables when an override is more visible than the base
If an override B.f() is more visible than a base method A.f(), it is
possible that an override C.f() of B.f() cannot see the original method
A.f().

In this case, we would encounter linker errors if we referenced the
method descriptor or method dispatch thunk for A.f().

Make this work by treating B.f() as the least derived method in this
case, and ensuring that the vtable thunk for B.f() dispatches through
the vtable again.

Fixes <rdar://problem/48330571>, <https://bugs.swift.org/browse/SR-10648>.
2019-06-01 00:08:05 -04:00
Doug Gregor
c02ecf9859 [SE-0258] Rename to Property Wrappers 2019-05-29 22:17:50 -07:00
Slava Pestov
c947eda18f AST: Use ProtocolDecl::getAssociatedTypeMembers() where possible 2019-05-28 22:08:31 -04:00
Arnold Schwaighofer
57362a8572 Fix documentation comments. 2019-05-28 07:14:57 -07:00
Arnold Schwaighofer
c187c8ac13 SIL: Replace uses of getReferencedFunction() by getReferencedFunctionOrNull() and getInitialReferencedFunction()
With the advent of dynamic_function_ref the actual callee of such a ref
my vary. Optimizations should not assume to know the content of a
function referenced by dynamic_function_ref. Introduce
getReferencedFunctionOrNull which will return null for such function
refs. And getInitialReferencedFunction to return the referenced
function.
Use as appropriate.

rdar://50959798
2019-05-26 08:58:14 -07:00
Andrew Trick
bdf7b2ade6 Merge pull request #24947 from atrick/fix-dynamic-exclusivity
Fix exclusivity diagnostics to be aware of [dynamically_replaceable].
2019-05-22 10:36:01 -07:00
swift-ci
b170ad72a8 Merge pull request #24953 from gottesmm/pr-71990c28f613fe44d9bf454eeb0b89a4356c8f91 2019-05-21 10:40:51 -07:00