Commit Graph

9332 Commits

Author SHA1 Message Date
Chris Lattner
c7373c563b add regular convenience methods to SIL IR objects for getting parent containers.
Add a getOperand(n) method to SILInstruction.


Swift SVN r6425
2013-07-21 06:12:29 +00:00
Chris Lattner
eccf04f52e struct_element_addr doesn't cause an alloc_box to escape if the
result of the struct_element_addr doesn't escape.


Swift SVN r6424
2013-07-21 05:56:28 +00:00
Chris Lattner
211f295b28 generalize getLastRelease to handle the "exciting" case when we have multiple releases of a box, potentially spread all across the CFG.
Swift SVN r6423
2013-07-21 05:31:09 +00:00
Chris Lattner
4617eaf214 Teach alloc_box promotion to insert a destroy_addr and dealloc_stack instruction
at the end of a variables lifetime.  Right now, this is only handles the most
simple case, but it should be conservatively correct now.

This also inserts destroy_addr instructions even for trivial instructions.  If
there is a way for SIL passes to query a SILType for triviality, this can be
easily fixed.


Swift SVN r6422
2013-07-21 05:10:52 +00:00
Chris Lattner
a9e92a2b61 Expose basic post-dominance information.
Swift SVN r6421
2013-07-21 04:29:29 +00:00
Chris Lattner
9d8a4aeff9 initialize_var doesn't cause alloc_box to escape.
Swift SVN r6413
2013-07-20 02:45:36 +00:00
Chris Lattner
496446ce64 Make all SIL objects that are print()-able, also raw_ostream insertable
with <<.  Use this to implement a DEBUG() dump in MemoryPromotion.cpp


Swift SVN r6412
2013-07-20 02:43:26 +00:00
Chris Lattner
8638600923 simplify a SILBuilder constructor.
Swift SVN r6410
2013-07-20 01:58:36 +00:00
Chris Lattner
61bedf868a implement a trivial SIL-level "escape analysis" pass that promotes alloc_box to
alloc_stack.


Swift SVN r6409
2013-07-20 01:57:34 +00:00
Chris Lattner
f8c8eb1037 add some helper methods for IR passes to use.
Swift SVN r6407
2013-07-20 01:36:46 +00:00
Chris Lattner
d528b49fca make getElementType() methods on SIL allocation instructions return a SILType.
This points out that perhaps IRGen's HeapArrayInfo should traffic in SILTypes
instead of CanTypes.  I did the minimal update though.


Swift SVN r6405
2013-07-20 01:25:20 +00:00
Joe Groff
10f290a01d AST: Add slot for substitutions for generic witnesses.
If a protocol requirement is satisfied by a generic method, we'll need to save the substitutions necessary to call that method from the witness thunk. This patch adds the spot in the ProtocolConformance::Mapping to save the substitutions; for now, always leave it empty and update the code for the type change.

Swift SVN r6399
2013-07-20 00:08:43 +00:00
Anna Zaks
b90fd7f39e Remove redundant code.
As per Doug’s review of r6356.

Swift SVN r6391
2013-07-19 21:28:47 +00:00
Chris Lattner
cccf26b9b0 rename [de]alloc_var -> [de]alloc_stack in the printed and parsed sil syntax.
Swift SVN r6389
2013-07-19 21:18:20 +00:00
Chris Lattner
47dd7a4cf4 rename SIL internals for AllocVar and DeallocVar to [De]AllocStack.
No syntax change yet.


Swift SVN r6382
2013-07-19 19:38:29 +00:00
John McCall
69b64a09ce More canonical type preserving.
Swift SVN r6377
2013-07-19 07:08:38 +00:00
John McCall
4b4e7d0833 Eliminate SIL and IR-gen's TypeVisitor specializations in
favor of a new AST-level one, and exploit it.

Swift SVN r6376
2013-07-19 07:08:34 +00:00
John McCall
d710c0f5f2 Use the type-in-context in the ExtensionDecl for a generic type.
This is a temporary hack until we properly make these carry
their own generic parameters.

This removes the last valid way to get UnboundGenericTypes in
a checked program.

Swift SVN r6373
2013-07-19 03:10:10 +00:00
Argyrios Kyrtzidis
ff072270c7 Use CanType in the Mangler API.
Swift SVN r6369
2013-07-19 00:47:58 +00:00
John McCall
16063866ed Preserve type canonicality with isa/cast/dyn_cast.
Swift SVN r6362
2013-07-18 23:28:53 +00:00
Anna Zaks
3df60fc9a4 [SIL diagnostics] Teach "missing return" warning about noreturn attribute
Swift SVN r6360
2013-07-18 22:57:23 +00:00
Anna Zaks
92e07c6a54 Use ExtInfo struct to pass around call related info in FunctionType and PolymorphicFunctionType getters.
Swift SVN r6358
2013-07-18 22:57:21 +00:00
Doug Gregor
ad1a9ac2c3 Eliminate default argument expressions from the type system.
Elements of a tuple type now know if there is a default argument, and
what kind of default argument it is (callee side, __FILE__, __LINE__,
__COLUMN__), but they don't have an actual expression. There are a
number of cleanups this enables that will follow. 

Note that the serialization support is as-yet-untested.


Swift SVN r6351
2013-07-18 18:49:32 +00:00
Manman Ren
457f27ccac SIL Parser: parse archetype_metatype, associated_metatype, class_metatype and
protocol_metatype.

Print type to enable parsing.


Swift SVN r6350
2013-07-18 18:49:04 +00:00
Doug Gregor
6804b23564 Teach scalar-to-tuple conversions to use the resilient entry points for default arguments.
There is a bunch of copy-and-paste here from the tuple-shuffle
code. The expected trajectory is that ScalarToTupleExpr will grow into
a general TupleConversionExpr, obviating the need for TupleShuffleExpr
entirely and eliminating the redundancy.



Swift SVN r6347
2013-07-18 17:23:33 +00:00
Joe Groff
9917e5ff09 SIL: Assert that bridged types actually exist.
Instead of quietly not bridging. If the Clang importer and other module importers did their job correctly, there's no way the bridge types shouldn't be there at SILGen time. Rearrange the checks to always look for the native type first; if we never see a String, we don't also need to see an NSString, which could legitimately be missing if we didn't import Foundation and don't use any NSString APIs.

Swift SVN r6340
2013-07-17 23:11:34 +00:00
Joe Groff
8e56e45f22 SIL: Define a switch_oneof instruction.
This instruction encapsulates testing, branching, and destructuring a oneof, as in:

oneof Expr {
  case True
  case False
  case IntLiteral(Int)
  case StringLiteral(String)
}

sil @dispatch_expr : $(Expr) -> () {
entry(%expr : $Expr):
  switch_oneof %expr, \
    case #Expr.True!oneofelt : bb1, \
    case #Expr.False!oneofelt : bb2, \
    case #Expr.IntLiteral!oneofelt : bb3, \
    default bb4
bb1:
  ...
bb2:
  ...
bb3(%int : $Int):
  ...
bb4:
  ...
}

Swift SVN r6329
2013-07-17 16:55:29 +00:00
Manman Ren
ee8e504b79 SIL Parser: parse ref_element_addr.
Print type to enable parsing.


Swift SVN r6316
2013-07-17 01:06:28 +00:00
Manman Ren
04c146855f SIL Parser: parse tuple_element_addr and tuple_extract.
Print type to enable parsing.


Swift SVN r6312
2013-07-17 00:31:42 +00:00
Manman Ren
36dd7bfa84 SIL Parser: parse builtin_zero, struct, struct_element_addr, and struct_extract.
Print type for struct_extract and struct_element_addr to enable parsing.


Swift SVN r6308
2013-07-16 23:23:20 +00:00
Doug Gregor
423abc5038 Codify the default argument hack for __FILE__/__LINE__/__COLUMN__.
Teach TuplePatternElt to keep track of the kind of the default
argument: none, normal (provided by calling into the appropriate
callee generator), __FILE__, __LINE__, or __COLUMN__. For the latter
three cases, the type checker forms the appropriate argument as part
of the call. 

The actual default argument expression will only be held in the tuple
pattern element when we've parsed it; it won't be serialized or
deserialized, because only the defining module cares. This is a step
toward eliminate the initialization expression from tuple types.

The extension to TupleShuffleExpr is a hack, which will also be
replicated in ScalarToTupleExpr, until we finally rework the
representation of TupleShuffleExpr (<rdar://problem/12340004>).


Swift SVN r6299
2013-07-16 22:52:38 +00:00
Argyrios Kyrtzidis
eeff2b207f [SIL] Mangler::mangleType should be mangling canonical types.
Swift SVN r6296
2013-07-16 20:41:55 +00:00
Doug Gregor
78692b76e8 Use default argument generators to create default argument values.
This change switches SIL generation for default values over to using
the default argument generators we started emitting in r6258. Note
that we don't use these entry points for default arguments involving
__FILE__, __LINE__, or __COLUMN___. These will need a different kind
of magic.


Swift SVN r6295
2013-07-16 20:32:47 +00:00
Anna Zaks
a984d9b24c Move the SIL diagnostic emission entrypoint from SILGen to the top level swift.cpp driver
This addresses Chris’s review of r6151.

Swift SVN r6290
2013-07-16 18:53:23 +00:00
Anna Zaks
c00ccc2876 Rename dataflow diagnostics file and remove the redundant visitor.
Partially, addresses Chris's review of r6151.

Swift SVN r6286
2013-07-16 01:50:32 +00:00
Anna Zaks
f6d1ec48f0 [SIL] Refactor SILLocation not to derive from PointerUnion3 but to include it as a member
As per Chris's suggestion (review of r6152), further refactored SILLocation not to derive from PointerUnion3 but to include it as a member.

In addition, added some template magic to make sure we don't have to chain dyn_casts, which I suspect will be/is happening a lot with SILLocation:
Ex:
-  if (auto E = Func.dyn_cast<Expr*>()) {
-    if (const FuncExpr *FE = dyn_cast<FuncExpr>(E))
-      return SILLocation(FE->getBody())
+  if (const FuncExpr *FE = Func.getAs<FuncExpr>())
+    return SILLocation(FE->getBody());

Swift SVN r6283
2013-07-16 01:50:29 +00:00
Dmitri Hrybenko
aa46064432 Pass a const ASTContext and const DeclContext whenever possible. This makes it
possible to use lookupVisibleDecls() with a const DeclContext.


Swift SVN r6274
2013-07-15 23:39:00 +00:00
Manman Ren
1d507f2e42 SIL Parser: parse copy_addr and upcast_existential.
Modify SILPrinter to print necessary types for parsing.
Format of copy_addr is changed from
  copy_addr Src [take]? to Dst [initialization]?
  to
  copy_addr [take]? Src to [initialization]? Dst : DstType
to put the attribute in front of the actual value.
It also makes parsing easier since '[' can start an array type.


Swift SVN r6268
2013-07-15 19:06:32 +00:00
Dmitri Hrybenko
98aaf3bb45 Add code completion for expr-super: 'super#^A^#' and 'super.#^A^#'
Swift SVN r6264
2013-07-15 18:11:48 +00:00
Doug Gregor
a12d30d9b1 Emit entrypoints for the default argument generator functions.
In the resilience model for default arguments, the presence of a
default argument is API, but its specific value is not. Thus, the
actual default argument values can evolve over time. To implement
this, for each default argument, we emit a function that
takes no arguments and produces the default value for that
argument. The caller will then call that function to form the default
argument.

This commit emits these functions for each default argument, even
though they are not currently being called. This is part of
<rdar://problem/11561185>.

We'll probably want a different calling convention for these functions
that preserves all registers, since they will often end up being very
trivial functions. 




Swift SVN r6260
2013-07-15 17:34:22 +00:00
Chris Lattner
12872e5190 remove the allocation kind enum from alloc_var/dealloc_var/alloc_ref. There is
only one kind now: stack.  alloc_var is just for stack memory now.


Swift SVN r6256
2013-07-15 16:48:56 +00:00
Chris Lattner
c5a2ac7b96 push some incremental work to the tree. This isn't useful by itself, but I want to
detangle it from other cleanups happening.


Swift SVN r6255
2013-07-15 16:39:16 +00:00
Chris Lattner
5322275156 remove the 'heap' form of alloc_var. It is not used, and the imagined
possible use cases are far enough away that we shouldn't worry about them
now.


Swift SVN r6253
2013-07-15 16:33:09 +00:00
Chris Lattner
5c1320042c remove the "pseudo" class of alloc_var. It is not used.
Swift SVN r6252
2013-07-15 16:25:19 +00:00
Chris Lattner
ba4c64479c Have -emit-sil[gen] print a couple of import options. This is a hack (the right answer
is to print all referenced decls at the start of a .sil file), but it is a useful hack.



Swift SVN r6251
2013-07-15 15:49:29 +00:00
Chris Lattner
653ff95683 Add two files I forgot to 'svn add', hopefully unbreaking the b0t.
Swift SVN r6248
2013-07-15 15:27:28 +00:00
Chris Lattner
1277ac7e04 Carve out a new lib/SIL/Passes directory to hold future SIL optimizations
and dataflow warnings.  Add a skeletal MemoryPromotion entrypoint as the first
exemplar.


Swift SVN r6247
2013-07-15 14:51:37 +00:00
Doug Gregor
d42e385371 Remove UnstructuredUnresolvedType.
Swift SVN r6241
2013-07-13 05:10:38 +00:00
Joe Groff
3b21e6a201 Add a OneOfElementPattern AST node type.
Add a node for references to oneof cases in patterns. No user-facing functionality change yet.

Swift SVN r6239
2013-07-13 01:21:31 +00:00
Argyrios Kyrtzidis
b7817e4879 Remove VarargBaseTy field from TupleTypeElt.
Use a bit to indicate whether the element is a vararg one and infer the
VarargBase type via the element type.

Swift SVN r6220
2013-07-12 22:24:31 +00:00