Commit Graph

893 Commits

Author SHA1 Message Date
Slava Pestov
46bc2b160d SILGen: Remove 'overrideLocationForMagicIdentifiers' hack 2017-06-11 21:54:41 -07:00
John McCall
44fda629aa Teach SILGen to handle more bridging cases and thread SGFContexts
through a few places.

This patch should be NFC for existing patterns, but it's preparing for
using SILGen's built-in bridging capabilities for more things.
2017-06-11 01:39:51 -04:00
John McCall
f4a181bc21 Various improvements to RValue. 2017-06-11 01:39:50 -04:00
Slava Pestov
5b7b6d0b5e SILGen: Fix super_method calls from class method returning Self
Calls of superclass methods across module boundaries appear to use
the super_method instruction, even if the module was not built
with resilience.

This instruction was being created with a value having a dynamic
Self type, which tripped up the SIL verifier; with the verifier
disabled we would crash in IRGen.

Fixes <rdar://problem/32667187>.
2017-06-08 22:32:07 -07:00
Slava Pestov
6d9886f362 SILGen: Scrap ArchetypeCalleeBuilder altogether
The prepareArchetypeCallee() function no longer does
anything useful beyond calling Callee::forArchetype(),
so just replace all uses of the former with the latter.
2017-06-02 01:40:57 -07:00
Slava Pestov
b65ad58441 SILGen: Remove ArchetypeCalleeBuilder::shouldMaterializeSelf()
I don't think any of this was necessary anymore, and
I suspect it was working around other related issues
that have since been fixed.

Whatever we did to 'self' here we also would have
had to do for extension methods anyway.

Note that some tests changed but I believe the end
result should be equivalent.
2017-06-02 01:40:56 -07:00
Slava Pestov
29cd885996 SILGen: Remove SILGenFunction::ArchetypeOpenings
SILBuilder now tracks data dependencies between instructions
that open existentials and uses of the opened type, so
SILGen's mechanism for this is no longer needed.

In particular, this simplifies ArchetypeCalleeBuilder.
2017-06-02 01:35:11 -07:00
Slava Pestov
c28c420a1f SILGen: Simplify SILGenApply a bit
We were passing around a ton of unused parameters,
just remove them.
2017-06-02 01:35:01 -07:00
Robert Widmann
3b202c18d8 Use 'hasAssociatedValues'
Use 'hasAssociatedValues' instead of computing and discarding the
interface type of an enum element decl.  This change has specifically not
been made in conditions that use the presence or absence of the
interface type, only conditions that depend on the presence or absence
of associated values in the enum element decl.
2017-05-22 09:54:47 -07:00
Slava Pestov
775462bf52 SILGen: Don't model closure captures as an 'uncurry level' 2017-05-09 00:56:36 -07:00
Slava Pestov
edb1e97a35 SIL: Remove uncurryLevel from SILDeclRef
All we need to store is whether the SILDeclRef directly
references the declaration, or if it references a curry
thunk, and we already have an isCurried bit for that.
2017-05-09 00:56:35 -07:00
Slava Pestov
59ed555b09 SIL: Simplify SILDeclRef constructor usages 2017-05-09 00:16:47 -07:00
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00
Joe Shajrawi
d17258cac7 @in_constant calling convention - part of passing large loadable types by address 2017-04-30 10:13:02 -07:00
John McCall
338825e73d Fix the emission of r-value pointer conversions to delay the
conversions and extend lifetimes over the call.

Apply this logic to string-to-pointer conversions as well as
array-to-pointer conversions.

Fix the AST verifier to not blow up on optional pointer conversions,
and make sure we SILGen them correctly.  There's still an AST bug
here, but I'll fix that in a follow-up patch.
2017-04-26 14:15:44 -04:00
John McCall
f7e73ccc48 Delay the formal accesses associated with inout-to-pointer and
array-to-pointer argument conversions until just before the call.

rdar://31781386
2017-04-25 03:54:49 -04:00
John McCall
0d4e0a961d Fix the writeback-conflict diagnostic to look through access markers.
We're now double-diagnosing some things that are caught by both
SILGen and static enforcement; we can fix that later, but I want to
unblock this problem first.
2017-04-24 02:02:47 -04:00
Slava Pestov
d58f049608 AST: Introduce ASTContext::getAnyObjectType()
This replaces a number of usages of KnownProtocolKind::AnyObject,
which is soon going away.
2017-04-13 21:17:05 -07:00
Arnold Schwaighofer
69e6f07167 Merge pull request #8701 from aschwaighofer/wip_ast_silgen_const_string_literal
AST/SILGen support for constant string literals
2017-04-12 09:52:18 -07:00
practicalswift
7684e73388 Merge pull request #8706 from practicalswift/excess-logic
[gardening] Remove redundant logic
2017-04-12 09:51:49 +02:00
practicalswift
5e255e07d7 [gardening] Remove redundant logic 2017-04-11 23:04:55 +02:00
Arnold Schwaighofer
4d60ec333b AST/SILGen support for constant string literals
rdar://30545013
2017-04-11 11:41:43 -07:00
Michael Gottesman
2e40219be7 [silgen] Convert else-if in a for-loop into a if continue. 2017-04-11 09:16:40 -07:00
Michael Gottesman
0b341359c7 [silgen] Refactor emitShuffle (~300 loc) into smaller methods (< 90 loc) on TupleShuffleArgEmitter.
This should be a pure NFC refactor. I just moved function scope state into the
helper struct and split up the already nicely scoped parts of the function into
separate methods if they were large.

In future commits, there are a bunch of improvements that can be made by
reducing indentation.
2017-04-10 20:40:27 -07:00
Michael Gottesman
7e1198420a [gardening] Fix indentation of code in anonymous namespace to match LLVM style.
This just moves the code in by 1 indentation level.
2017-04-10 16:16:17 -07:00
Michael Gottesman
2224584997 [semantic-arc-opts] Teach semantic arc opts how to handle (borrow (copy)) of a guaranteed argument.
rdar://29870610
2017-04-06 16:23:02 -07:00
John McCall
e44f37fd8d Thread an enforcement kind through a few places. NFC. 2017-04-05 01:25:35 -04:00
John McCall
305c94fc5b Pare down the Initialization interface and allow implementations
to insert code before performing an in-place initialization.

Intended to be NFC, but some of the clients needed more rewriting
than others.
2017-03-31 18:55:09 -04:00
Michael Gottesman
ba5be9d8e8 [silgen] Eliminate an unnecessary writeback scope.
This writeback scope's writeback is handled by the ArgumentScope for argument
emission. Since the scope will be destroyed after argument scope, we get
mismatched scope depths.

rdar://31313534
2017-03-30 14:51:53 -07:00
Michael Gottesman
08c9d4dd11 [silgen] Verify FormalEvaluationScopes in certain places in SILGenApply.
We probably could put it in more places, but this is a good first start.

rdar://31313534
2017-03-30 13:20:50 -07:00
Slava Pestov
8fe8b89b0f SIL: Terminology change: [fragile] => [serialized]
Also, add a third [serializable] state for functions whose bodies we
*can* serialize, but only do so if they're referenced from another
serialized function.

This will be used for bodies synthesized for imported definitions,
such as init(rawValue:), etc, and various thunks, but for now this
change is NFC.
2017-03-29 16:47:28 -07:00
swift-ci
c56709ffeb Merge pull request #8356 from gottesmm/partial_reapply_41f425a5033a30fdd545752b8bb10374bbf1de12 2017-03-26 14:16:43 -07:00
Michael Gottesman
f9e3b1d6d9 Reapply "[silgen] If we have a direct guaranteed convention and have an owned value, perform a borrow.""
This partially reverts commit 41f425a503.

The key thing is that now it is behind the semantic sil flag. I have an
additional patch that turns this back on in front of the flag, but it requires a
little bit of mandatory pass work that Erik is going to hit this week.

rdar://31145255
2017-03-26 12:56:42 -07:00
Hugh Bellamy
b6e720ab96 Fix undefined behaviour caused by accessing uninitialized field in CallEmission 2017-03-25 12:54:21 +07:00
Slava Pestov
7aabd80898 SIL: Stub out TypeConverter::getOverriddenVTableEntry()
This replaces SILDeclRef::getBaseOverriddenVTableEntry(). It lives
in the TypeConverter because it needs to use type lowering information
to determine if the method requires a new vtable entry or not.
2017-03-24 01:53:39 -07:00
Michael Gottesman
54a97bbf53 [silgen] Scope ArgEmitter::emit{SubstToOrigValue,NativeToBridgedArgument} using popPreservingValue to move its result into the outer scope.
rdar://31145255
2017-03-22 14:55:03 -07:00
Michael Gottesman
41f425a503 Revert "[silgen] If we have a direct guaranteed convention and have an owned value, perform a borrow."
This reverts commit 4c8595b002.
2017-03-20 05:00:31 -07:00
Devin Coughlin
fdd9ea6c7d SILGen: Reapply 'Add experimental TSan instrumentation for inout accesses.'
(This re-applies #7736 with an update to the
tsan-inout.swift execution test to handle configurations where
TSan's ignore_interceptors_accesses is enabled by default.)

Add SILGen instrumentation to treat inout accesses as Thread Sanitizer writes.
The goal is to catch races on inout accesses even when there is a not an
llvm-level read/write to a particular address. Ultimately
this will enable TSan to, for example, report racy writes to distinct
stored properties of a common struct as a data race.

This instrumentation is off by default. It can be enabled with the
'enable-experimental-tsan-inout-instrumentation' frontend flag.

The high-level approach is to add a SIL-level builtin that represents a call
to a TSan routine in compiler-rt. Then, when emitting an address for an LValue
as part of an inout expression, we call this builtin for each path component
that represents an LValue. I've added an 'isRValue()' method to PathComponent
that tracks whether a component represents an RValue or an LValue. Right the
only PathComponent that sometimes returns 'true' is ValueComponent().

For now, we're instrumenting only InoutExprs, but in the future it probably
makes sense to instrument all LValue accesses. In this patch I've
added a 'TSanKind' parameter to SILGenFunction::emitAddressOfLValue() and
its helpers to limit instrumentation to inout accesses. I envision that this
parameter will eventually go away.
2017-03-18 20:10:19 -07:00
Michael Gottesman
4c8595b002 [silgen] If we have a direct guaranteed convention and have an owned value, perform a borrow.
Now that all arguments are properly scoped, we do not need to worry about this
extending the lifetimes of COW times inappropriately.

rdar://30955427
2017-03-18 18:59:31 -07:00
Michael Gottesman
b99c47c006 [silgen] Scope argument cleanups with a new scope called "ArgumentScope".
Once this is in, I will be able to finish the SILGenApply part of Semantic SIL.

rdar://30955427
2017-03-18 17:03:41 -07:00
Michael Gottesman
8723301205 [silgen] Move implementation of emitForeignErrorArgument into ResultPlan. 2017-03-18 16:06:58 -07:00
Michael Gottesman
f4f41337e3 [gardening] Change some CalleeTypeInfo '&' parameters to be 'const &' parameters. NFC. 2017-03-18 14:40:50 -07:00
Greg Parker
c17cfb69d8 Revert "SILGen: Add experimental TSan instrumentation for inout accesses. (#7736)"
This reverts commit 52d5178a3e.
2017-03-16 21:11:58 -07:00
Devin Coughlin
52d5178a3e SILGen: Add experimental TSan instrumentation for inout accesses. (#7736)
Add SILGen instrumentation to treat inout accesses as Thread Sanitizer writes.
The goal is to catch races on inout accesses even when there is a not an
llvm-level read/write to a particular address. Ultimately
this will enable TSan to, for example, report racy writes to distinct
stored properties of a common struct as a data race.

This instrumentation is off by default. It can be enabled with the
'enable-experimental-tsan-inout-instrumentation' frontend flag.

The high-level approach is to add a SIL-level builtin that represents a call
to a TSan routine in compiler-rt. Then, when emitting an address for an LValue
as part of an inout expression, we call this builtin for each path component
that represents an LValue. I've added an 'isRValue()' method to PathComponent
that tracks whether a component represents an RValue or an LValue. Right the
only PathComponent that sometimes returns 'true' is ValueComponent().

For now, we're instrumenting only InoutExprs, but in the future it probably
makes sense to instrument all LValue accesses. In this patch I've
added a 'TSanKind' parameter to SILGenFunction::emitAddressOfLValue() and
its helpers to limit instrumentation to inout accesses. I envision that this
parameter will eventually go away.
2017-03-16 17:08:48 -07:00
Joe Shajrawi
067c867e5d Add inital support of Address-only enums under opaque values mode 2017-03-15 12:59:23 -07:00
Slava Pestov
61e9a980a7 SILGen: Calculate substituted formal type upfront
Also for class method callees, use the formal type of the base
method and not the override, fixing an issue with concrete
subclasses of generic base classes which bind a generic
parameter to a tuple type.

Fixes <https://bugs.swift.org/browse/SR-3541>.
2017-03-14 18:11:55 -07:00
Slava Pestov
708523d82e SILGen: Kill Callee::setSubstitutions() 2017-03-14 18:11:55 -07:00
Slava Pestov
f29661d40c SILGen: Callee::getOrigFormalType() is now an abstraction pattern 2017-03-14 18:11:55 -07:00
Slava Pestov
510d233543 SILGen: Refactor Callee a bit 2017-03-14 17:46:54 -07:00
Slava Pestov
64adf7495e SILGen: Change ArchetypeOpenings map to be keyed by ArchetypeType * and not CanType 2017-03-14 17:46:54 -07:00