Commit Graph

521 Commits

Author SHA1 Message Date
Arnold Schwaighofer
c322b3592d Add a data dependence between opened existential values and method_inst that 'use' them.
Before this patch there was no dependence visible to the optimizer between a
open_existential and the witness_method allowing the optimizer to reorder the
two instruction. The dependence was implicit in the opened archetype but this
is not a concept model by the SIL optimizer.

  %2 = open_existential %0 : $*FooProto to $*@opened("...") FooProto
  %3 = witness_method $@opened("...") FooProto,
                      #FooProto.bar!1 : $@cc(...)
  %4 = apply %3<...>(%2)

This patch changes the SIL representation such that witness_methods on opened
archetypes take the open_existential (or the producer of the opened existential)
as an operand preventing the optimizer from reordering them.

  %2 = open_existential %0 : $*FooProto to $*@opened("...") FooProto
  %3 = witness_method $@opened("...") FooProto,
                      #FooProto.bar!1,
                      %2 : $*@opened("...") FooProto : $@cc(...)
  %4 = apply %3<...>(%2)

rdar://18984526

Swift SVN r23438
2014-11-19 17:22:22 +00:00
Joe Groff
dc2ad382a2 Serialization: Serialize the raw values of @objc enums.
This is necessary for @objc enums because, for C compatibility, the representations of the cases must match their raw values. We might want to do this for sufficiently fragile Swift enums in the future too, but that can wait. This lets us successfully print the raw values as ObjC.

Swift SVN r23423
2014-11-19 04:03:06 +00:00
Doug Gregor
b27e88b70b Record Objective-C method lookup tables in Swift modules.
Include a mapping from Objective-C selectors to the @objc methods that
produce Objective-c methods with those selectors. Use this to lazily
populate the Objective-C method lookup tables in each class. This makes
@objc override checking work across Swift modules, which is part of
rdar://problem/18391046.

Note that we use a single, unified selector table, both because it is
simpler and because it makes global queries ("is there any method with
the given selector?") easier.

Swift SVN r23214
2014-11-11 00:19:03 +00:00
Doug Gregor
89e5e5b6fa Diagnose redeclarations of Objective-C methods.
@objc methods, initializers, deinitializers, properties, and
subscripts all produce Objective-C methods. Diagnose cases where two
such entities (which may be of different kinds) produce the same
Objective-C method in the same class.

As a special exception, one can have an Objective-C method in an
extension that conflicts with an Objective-C method in the original
class definition, so long as the original class definition is from a
different model. This reflects the reality in Objective-C that the
category definition wins over the original definition, and is used in
at least one overlay (SpriteKit).

This is the first part of rdar://problem/18391046; the second part
involves checking that overrides are sane.

Swift SVN r23147
2014-11-07 01:15:14 +00:00
Erik Eckstein
60cb1a619a Support for eliminated witness methods in SILWitnessTable.
A method entry in SILWitnessTable can now be null.
This will be needed by dead method elimination.



Swift SVN r22914
2014-10-24 16:26:12 +00:00
Erik Eckstein
3eea8e3052 Set SILLinkage of witness tables according to the protocol visibility.
This is the same change as already done for functions and globals
(for details see <rdar://problem/18201785>).




Swift SVN r22907
2014-10-24 09:02:05 +00:00
Joe Groff
ea65d1e60b SIL: Remove the builtin_function_ref instruction.
Swift SVN r22797
2014-10-16 16:18:40 +00:00
Joe Groff
a60a52d72e SIL: Add a "builtin" instruction to represent builtin invocations.
Modeling builtins as first-class function values doesn't really make sense because there's no real function value to emit, and modeling them this way complicates passes that work with builtins because they have to invent function types for builtin invocations. It's much more straightforward to have a single instruction that references the builtin by ID, along with the type information for the necessary values, type parameters, and results, so add a new "builtin" instruction that directly represents a builtin invocation. NFC yet.

Swift SVN r22690
2014-10-11 20:34:24 +00:00
Doug Gregor
59a355a67b Eliminate the notion of an archetype "index"; it's useless now. NFC
Swift SVN r22644
2014-10-09 22:43:54 +00:00
Joe Groff
9205bf64cf SIL: Remove enum_is_tag.
Swift SVN r22616
2014-10-09 05:03:43 +00:00
Joe Groff
ca8b168188 SIL: Add select_enum and select_enum_addr insns.
Similar to LLVM's "select" instruction, the instruction picks one of its operands based on the case tag of an enum value.

Swift SVN r22578
2014-10-07 21:45:08 +00:00
Jordan Rose
24720ab462 [serialization] Make serialization::DefaultArgumentKind an enum class.
...because it has an enumerator named "None", which conflicts with llvm::None.

Swift SVN r22475
2014-10-02 18:51:39 +00:00
Joe Groff
3a606b9eb8 SIL: Drop the protocol_method instruction.
Swift SVN r22446
2014-10-01 23:35:41 +00:00
John McCall
dcfbc3c607 Briefly describe the last change made to the serialization
format on the minor-version line.  The goal here is to
cause merge conflicts instead of silently merging two
identical version bumps.

Swift SVN r22391
2014-09-30 17:20:31 +00:00
John McCall
dc1831940b Missing bits of r22381: make something a bitfield
that was meant to be and bump the serialization
version.

Swift SVN r22390
2014-09-30 17:09:36 +00:00
John McCall
8c303ef7a6 Representational changes towards get-and-mutableAddress
properties.

The main design change here is that, rather than having
purportedly orthogonal storage kinds and has-addressor
bits, I've merged them into an exhaustive enum of the
possibilities.  I've also split the observing storage kind
into stored-observing and inherited-observing cases, which
is possible to do in the parser because the latter are
always marked 'override' and the former aren't.  This
should lead to much better consideration for inheriting
observers, which were otherwise very easy to forget about.
It also gives us much better recovery when override checking
fails before we can identify the overridden declaration;
previously, we would end up spuriously considering the
override to be a stored property despite the user's
clearly expressed intent.

Swift SVN r22381
2014-09-30 08:39:38 +00:00
Joe Groff
152aa9e244 Revert "SIL: Drop the upcast_existential* instructions."
This reverts commit r22345.

Swift SVN r22353
2014-09-29 13:46:41 +00:00
Joe Groff
1e343fb430 SIL: Drop the upcast_existential* instructions.
Swift SVN r22345
2014-09-28 19:24:33 +00:00
Joe Groff
0518f2067f Revert "SIL: Drop the upcast_existential* instructions."
This reverts commit r22333.

Swift SVN r22337
2014-09-28 18:41:05 +00:00
Joe Groff
727c9b5ed7 SIL: Drop the upcast_existential* instructions.
Swift SVN r22333
2014-09-28 16:38:13 +00:00
Joe Groff
a3126706da SIL: Eliminate the dead 'alloc_array' insn.
Swift SVN r22292
2014-09-26 02:28:10 +00:00
Doug Gregor
e0afb13abb Remove the APINotes library; it lives in Clang, now.
Swift SVN r22286
2014-09-25 18:48:43 +00:00
John McCall
aa32a4401d Bump the module file format version for the addressor changes.
I could've sworn I remembered to do this this time.  Argh.

Swift SVN r22251
2014-09-24 01:00:50 +00:00
Jordan Rose
06986b7dca Re-apply the series of commits to remove redundantly-serialized conformances.
I can't actually reproduce the buildbot failure that happened last night, so
hopefully it will (a) happen again, so I can investigate, or (b) not happen
again.

Swift SVN r22230
2014-09-23 20:50:51 +00:00
John McCall
16cb523c3a AST support for accessors.
Swift SVN r22228
2014-09-23 20:34:19 +00:00
Doug Gregor
6559392293 Start re-namespacing APINotes and its dependencies.
FixNum.h and BCRecordLayout.h will move down into LLVM, APINotes
will move into Clang. Get the namespaces right before we start to move
files around.

Swift SVN r22218
2014-09-23 17:52:17 +00:00
Dmitri Hrybenko
45c2005c9d Revert the series of commits to remove redundantly-serialized
conformances (22195 to 22199).

It broke tests:

Failing Tests (4):
   Swift :: Interpreter/SDK/Foundation_NSString.swift
   Swift :: SIL/Serialization/deserialize_appkit.sil
   Swift :: SIL/Serialization/deserialize_foundation.sil
   Swift :: stdlib/NSStringAPI.swift

Swift SVN r22214
2014-09-23 11:40:23 +00:00
Jordan Rose
988b8c2033 [Serialization] Preserve a deinitializer's interface type.
We haven't actually needed this for anything, but we should probably follow
the invariants of the AST.

Swift SVN r22199
2014-09-23 02:06:25 +00:00
Jordan Rose
7fe346a091 [Serialization] Preserve the decl context for a NormalProtocolConformance.
Doug had changed the comment but not the implementation -- we were still
serializing the containing module rather than the declaring nominal or
extension.

Found by enabling verification on deserialized decls (to come soon).

Swift SVN r22198
2014-09-23 02:06:24 +00:00
Jordan Rose
eea6c17456 [Serialization] init_existential should reference existing conformances.
Part of a series of commits to remove redundantly-serialized conformances.

Swift SVN r22195
2014-09-23 02:06:20 +00:00
Doug Gregor
3119e6d345 Remove the tables that track the types that conform to "known" protocols.
The type checker no longer needs them.


Swift SVN r22137
2014-09-19 16:41:26 +00:00
John McCall
31d2cac2b3 Bump the serialization minor version.
I forgot to do this as part of the materializeForSet changes.

Swift SVN r22064
2014-09-18 06:01:29 +00:00
John McCall
7ae26ffd05 Serialize the materializeForSet accessor of a subscript.
Swift SVN r22016
2014-09-17 08:08:10 +00:00
John McCall
75050f8166 Generate an implicit 'materializeForSet' accessor
along with getters and setters.

Just generate it for now.

Swift SVN r22011
2014-09-17 08:08:03 +00:00
Dmitri Hrybenko
fad578b304 stdlib: remove ArrayBonudType
Swift SVN r21991
2014-09-16 22:42:33 +00:00
Joe Groff
8338e69c86 Actually set up the 'rawValue' argument label on derived enum initializers.
Somehow, protocol conformance checking didn't actually care that this was missing...

Swift SVN r21898
2014-09-12 01:29:51 +00:00
Manman Ren
9491a0e190 [Global Opt] get ready to replace GlobalAddrInst with SILGlobalAddrInst.
We add two more fields to SILGlobalVariable: a VarDecl and a flag to see if this
is a declaration. VarDecl is mainly used for debugger support, it is also used
to check if the variable is weak imported.

We also modify the serializer to serialize the extra two fields.


Swift SVN r21883
2014-09-11 18:13:04 +00:00
Joe Groff
d7c98dcff4 Add an @NSApplicationMain attribute.
This behaves like @UIApplicationMain, except for AppKit. Attach it to your NSApplicationDelegate, and an artificial "main" will be generated that invokes NSApplicationMain() for you. Implements rdar://problem/16904667.

Swift SVN r21697
2014-09-04 05:52:26 +00:00
Jordan Rose
1b51b60e72 [Serialization] Preserve private discriminators through serialization.
Part of rdar://problem/17632175

Swift SVN r21611
2014-08-30 17:27:02 +00:00
Jordan Rose
422565100e [Serialization] Keep track of whether a module has an underlying Clang module.
Previously, we depended on whether or not a serialized module was located
within a framework bundle to consider whether or not it may have a "Clang
half". However, LLDB loads serialized modules from dSYM bundles. Rather
than try to figure out if such a module is "really" a framework, just track
whether the original module was built with -import-underlying-module. If so,
consider the underlying Clang module to be re-exported.

rdar://problem/18099523

Swift SVN r21544
2014-08-28 21:36:02 +00:00
Doug Gregor
51c1433ddd Add magic "literal" __DSO_HANDLE__ to refer to the DSO handle.
__DSO_HANDLE__ can be used as a callee-side default
argument. Addresses rdar://problem/17878114.


Swift SVN r21440
2014-08-25 16:33:54 +00:00
Doug Gregor
17716524c5 Handle CF <-> Objective-C toll-free-bridged conversions in the type checker.
Introduce an attribute that describes when a given CF type is
toll-free-bridged to an Objective-C class, and which class that
is. Use that information in the type checker to provide the CF <->
Objective-C toll-free-bridged conversions directly, rather than using
the user-defined conversion machinery.

Swift SVN r21376
2014-08-21 21:36:05 +00:00
Doug Gregor
64bd844e0e Parse failable initializers.
Parsing, representation, (de-)serialization, printing, and dumping for
failable initializers.


Swift SVN r21290
2014-08-19 18:41:30 +00:00
Arnold Schwaighofer
cd799f8e46 Revert "Add an inline(late) attribute"
This reverts commit r21286.

Discussions ongoing.

Swift SVN r21289
2014-08-19 18:15:25 +00:00
Arnold Schwaighofer
7aa62ce835 Add an inline(late) attribute
This disables inlining at the SIL level. LLVM inlining is still enabled. We can
use this to expose one function at the SIL level - which can participate in
dominance based optimizations but which is implemented in terms of a cheap check
and an expensive check (function call) that benefits from LLVM's inlining.

Example:

The inline(late) in the example below prevents inlining of the two checks. We
can now perform dominance based optimizations on isClassOrObjExistential.
Without blocking inlining the optimizations would apply to the sizeof check
only and we would have multiple expensive function calls.

@inline(late)
func isClassOrObjExistential(t: Type) -> Bool{
  return sizeof(t) == sizeof(AnyObject) &&
    swift_isClassOrObjExistential(t)
}

We do want inlining of this function to happen at the LLVM level because the
first check is constant folded away - IRGen replaces sizeof by constants.

rdar://17961249

Swift SVN r21286
2014-08-19 18:05:44 +00:00
Dmitri Hrybenko
938e7c2676 stdlib: introduce UnicodeScalarLiteralConvertible protocol
This allows UnicodeScalars to be constructed from an integer, rather
then from a string.  Not only this avoids an unnecessary memory
allocation (!) when creating a UnicodeScalar, this also allows the
compiler to statically check that the string contains a single scalar
value (in the same way the compiler checks that Character contains only
a single extended grapheme cluster).

rdar://17966622

Swift SVN r21198
2014-08-14 16:04:39 +00:00
Nadav Rotem
cd3ab60357 Fix an encoding bug.
Testcase in the next commit.



Swift SVN r21087
2014-08-07 07:20:31 +00:00
Nadav Rotem
8dd52d63cd Add the @effects(readonly/readnone/readwrite) attribute.
Swift SVN r21070
2014-08-06 18:48:20 +00:00
Doug Gregor
6bf57e9010 Revert "Serialization: introduce a conformance cross-reference so we don’t serialize normal protocol conformances in modules that didn’t declare them."
This reverts commit r20792.

Conflicts:
	include/swift/Serialization/ModuleFormat.h

Swift SVN r20834
2014-07-31 17:30:08 +00:00
Doug Gregor
ba040d9f21 Maintain the DeclContext of a NormalProtocolConformance as the type declaration or extension.
Previously, we only retained the module in which a normal protocol
conformance occurred, which meant we either had to go searching for
the appropriate extension (yuck) or do without that information. This
is part of the separating-extension-archetypes work.

Swift SVN r20793
2014-07-31 01:00:30 +00:00