Commit Graph

6078 Commits

Author SHA1 Message Date
Chris Lattner
a87028e57c Reject uses of noescape parameters that would cause them to escape. Namely, we only
allow the parameter to be caller, or captured by another no-escape closure.


Swift SVN r24121
2014-12-23 21:12:29 +00:00
Chris Lattner
21a7a6c89a Doug twisted my arm and convinced me that noescape was a better match for the semantics we’ll have here. NoCapture would be confusable with "this closure doesn’t have any captures, thus should be compatible with thin function types"
The attribute itself remains __'ized.



Swift SVN r24113
2014-12-23 17:52:10 +00:00
Erik Eckstein
5cffa73bbd Refactoring: extract some code of the inliner to the projection classes.
Michael, thanks for your comments!

This also adds support for tuples and enums in Projection::getOperandForAggregate().



Swift SVN r24112
2014-12-23 16:26:08 +00:00
Erik Eckstein
cf0030b587 Make isSlowPath() a public member of ColdBlockInfo.
Swift SVN r24108
2014-12-23 09:11:57 +00:00
Erik Eckstein
6d9a7a1045 Helper class for visiting basic blocks in dominance order.
It uses a worklist-based algorithm. In contrast to a recursive traversal algorithm,
it cannot cause a stack overflow for very deep dominator trees.



Swift SVN r24107
2014-12-23 09:09:34 +00:00
Chris Lattner
83591f9845 pull NumParameters out of SILFunctionTypeBitfields, and add static
asserts to ensure that SILFunctionTypeBitfields never overflows the
bitfield size.


Swift SVN r24083
2014-12-22 23:02:53 +00:00
Chris Lattner
0ea4b20931 fix several bugs that would cause the nocapture bit to get truncated off (because it is bit 9
and char can't hold it).


Swift SVN r24081
2014-12-22 22:11:02 +00:00
Chris Lattner
e349ee3a60 Start the implementation of a "nocapture" attribute, which is only valid on paramdecls.
This is part of rdar://16323038.  Because this hasn't been fully design reviewed and
implemented, I'm naming it as __nocapture for now.  It is blocking finishing off the
"improved let model" work.




Swift SVN r24079
2014-12-22 21:34:30 +00:00
Chris Lattner
407bad1445 remove @autoclosure as a type attribute. Recognize it in a parameter
list and produce a nice fixit, so that people using it have an obvious
upgrade path.


Swift SVN r24075
2014-12-22 20:14:56 +00:00
Michael Gottesman
1ae4002b6f Add the frontend flag '-external-pass-pipeline-filename'
This flag enables one to specify a json file that expresses a specific
pipeline in the following format:

[
  [
    "$PASS_MANAGER_ID",
    "run_n_times"|"run_to_fixed_point",
    $NUM_ITERATIONS,
    "$PASS1", "$PASS2", ...
  ],
  ...
]

This will make it easier to experiment with different pass pipelines by
allowing:

1. Automatic generation of pass pipelines without needing to recompile
   the compiler itself.
2. Simple scripting of pass pipelines via the json meta language.
3. Enabling the easy expression and reproducability of a specific
   pipeline ordering via radar.

In the next commit I will provide a python library for the generation of these
json files with a few types of pipeline generators already created.

Swift SVN r24055
2014-12-20 04:09:47 +00:00
Jordan Rose
75c6ec9def Start tracking lookups on AnyObject/AnyClass.
These form dependencies as well. Part of rdar://problem/19270018.

Swift SVN r24049
2014-12-20 01:59:01 +00:00
Chris Lattner
dcb5c23bac tweak comments for new syntax, NFC.
Swift SVN r24047
2014-12-20 00:14:34 +00:00
John McCall
94514d7a22 Fix an annoying spate of build warnings about variadic macro
application.

Swift SVN r24046
2014-12-19 23:57:08 +00:00
Chris Lattner
86c3c50157 Implement support for parsing declattrs on parameters. The only tricky
case is where there is no argument name, because declattrs and typeattrs
can be juxtaposed.



Swift SVN r24045
2014-12-19 23:42:12 +00:00
Chris Lattner
a6d07f98f6 start implementation of a new @autoclosure decl attribute. It doesn't do
everything the type attribute does (notably, doesn't work on parameters), 
but this includes the infrastructure to apply it in all the sordid places 
that need to be touched for type-adjusting declattributes on variables.



Swift SVN r24044
2014-12-19 23:01:59 +00:00
John McCall
f19c31fbec Add builtins for allocating, projecting, and deallocating
Builtin.UnsafeValueBuffer.

Swift SVN r24043
2014-12-19 22:41:13 +00:00
John McCall
24f41462db Change the materializeForSet callback to take the
value buffer inout, just for better typing.

Swift SVN r24041
2014-12-19 22:41:11 +00:00
Jordan Rose
14a2909cab Pass -L, -l, and -framework to REPL and interpret mode jobs.
...and then honor them.

While here, make -l a little more flexible (see interpret_with_options test).

rdar://problem/17830826, which unblocks the LLDB feature for the same.

Swift SVN r24033
2014-12-19 17:33:03 +00:00
Chris Lattner
f28c1b3a3d remove inadvertently added diagnostic
Swift SVN r24031
2014-12-19 06:54:26 +00:00
Chris Lattner
3a7d8df92b fix <rdar://problem/19259730> Using mutating methods in a struct initializer with a let property is rejected
while we're at it, improve the QoI for actually-invalid mutating method calls in struct initalizers.


Swift SVN r24030
2014-12-19 06:52:37 +00:00
Jordan Rose
43bcbb8f9e [Driver] Handle outstanding jobs by reading the build record.
r23968 wrote out a record of which source files were included in a build,
and whether they were succesfully compiled or not...and if not, whether
they were out of date because of a cascading or non-cascading dependency.
This commit uses that information to decide what files might need to be
rebuilt even if a particular input doesn't change and doesn't appear to
have any changed dependencies. The two interesting cases are:

- A file was going to be built last time, but the build was halted
  because of an error. Build it this time.
- One of the files was removed and thus we've lost a source of dependency
  information; rebuild everything!

rdar://problem/19270980

Swift SVN r24018
2014-12-18 21:24:18 +00:00
Andrew Trick
d84feff62b Add a changeBranchTarget helper.
I refactored, generalized, and cleaned up an existing helper.

I also removed hard-coded assumptions about successor indices.
There's no point giving CondBranch a true/false API if we don't respect it.

Swift SVN r24001
2014-12-18 01:26:45 +00:00
Andrew Trick
0899d2a2bc Resolve a visual name conflict.
Swift SVN r24000
2014-12-18 01:26:43 +00:00
Michael Gottesman
93b92a8f9f Add in Passes.def for metaprogramming with SILPassKinds.
This simplifies some code in SILOpt and SILPasses. The real reason to do it is
to use it to procedurally generate random pipelines.

Swift SVN r23996
2014-12-17 23:56:26 +00:00
John McCall
b6eb086af8 Add a rather hacky builtin function for constructing
a materializeForSet callback from a closure.

Swift SVN r23993
2014-12-17 22:23:26 +00:00
John McCall
5c8fbc704c Add SIL instructions to convert between thin functions
and raw pointers.

Swift SVN r23992
2014-12-17 22:23:15 +00:00
Connor Wakamo
3c555ac19b Made Decl's ClangNode storage support 32-bit platforms.
Previously, this storage required that alignof(void *) >= alignof(Decl). This is
true on 64-bit platforms, where these are both 8, but on 32-bit platforms
alignof(void *) is only 4.

This now allocates enough bytes to match the alignment of the Decl in question.
This does mean that a void * must fit in that alignment, but this is true on 32-
and 64-bit platforms, and a static_assert ensures that this is true at compile
time.

As part of this change, the logic for allocating memory for a Decl has been
refactored into a separate function, so that the logic for allocating space for
a ClangNode can be centralized.

Swift SVN r23990
2014-12-17 21:23:16 +00:00
Jordan Rose
9ddd23c0ff Invert DeclContext::is[Non]CascadingContextForLookup.
...and a few other things.

Attempting to remove a few negations to minimize confusion.
No intended functionality change.

Swift SVN r23970
2014-12-17 02:42:48 +00:00
Jordan Rose
99075516ce Use "cascading/non-" terms for dependencies instead of "private/non-".
"private" is a very overloaded term already. "Cascading" instead of
"non-private" is a bit more clear about what will happen with this sort
of lookup.

No functionality change. There are some double negatives I plan to clean
up in the next commit, but this one was supposed to be very mechanical.

Swift SVN r23969
2014-12-17 02:42:45 +00:00
Jordan Rose
94e7a284bd [Driver] Write out a record of which files were compiled in a build.
This is important because we might get part-way through the full
compilation, overwriting swiftdeps files as we go, and then encounter an
error. We don't want to lose information about any decls that have been
removed since the previous compile, so we propagate forward the information
we already have by saving it to a "build record" file.

More simply, this is necessary to track when a file is removed from a target.

The next commit will handle reading in this file at the start of a build.

Swift SVN r23968
2014-12-17 00:26:28 +00:00
Jordan Rose
c5547f7068 [Driver] Use return value instead of out parameter for buildOutputFileMap.
No functionality change, just a cleanup.

Swift SVN r23966
2014-12-17 00:26:25 +00:00
Jordan Rose
c385a9d43a [Driver] Make the "incremental" flag an explicit part of Compilation.
No functionality change. Laying groundwork for the next commit.

Swift SVN r23965
2014-12-17 00:26:23 +00:00
Erik Eckstein
31dd17a49f Add array.uninitialized semantics to ArrayCallKind, ArraySemanticsCall and the docs.
For completeness. NFC.



Swift SVN r23955
2014-12-16 13:28:18 +00:00
Michael Gottesman
c0b5b94cfc Move SelectValueInst to where the rest of the Select*Inst instructions are, not next to the switch instructions. NFC.
Swift SVN r23934
2014-12-15 05:22:40 +00:00
Michael Gottesman
b2e766ac04 [aa] Add SILArgument::getIncomingValue({unsigned, SILBasicBlock *}) to get an individual incoming value.
This rounds out the getIncomingValues. I am going to use these routines
when I teach AA about PHI nodes.

Swift SVN r23933
2014-12-15 05:22:40 +00:00
Michael Gottesman
7e39f33f98 [mangle] Include a pass id in the mangling, just to be careful.
I am starting to reuse manglings for different passes. I want to make sure that
when we reuse functions we actually get a function created by the same pass.

Swift SVN r23924
2014-12-14 10:29:11 +00:00
Michael Gottesman
45b5389854 [mangle] Add support for mangling CapturePromotion specializations and wire it up.
<rdar://problem/19216281>

Swift SVN r23923
2014-12-14 08:17:32 +00:00
Michael Gottesman
c4f3043280 [mangle] Specify sizes for various specialization enums and make the underlying type configurable via a using statement.
Also added comments about how various parts of the enum are
used (i.e. options vs option sets).

Swift SVN r23922
2014-12-14 08:17:31 +00:00
Michael Gottesman
1d637f510b [mangle] Convert FunctionSignatureSpecializationMangler::setArgumentClosureProp to use an ArgNo index instead of SILArgument *.
This matches the rest of the methods on FunctionSignatureSpecializationMangler.

Swift SVN r23921
2014-12-14 08:17:30 +00:00
Chris Lattner
9414378210 change maintenance of "ParentPattern" in VarDecl to be implicitly handled by PatternBindingDecl itself, instead of having all clients do it.
Swift SVN r23918
2014-12-13 07:35:34 +00:00
Chris Lattner
6d753c6c87 merge two diagnostics.
Swift SVN r23917
2014-12-13 07:29:00 +00:00
Chris Lattner
a048b078e3 Implement: <rdar://problem/16181314> don't require immediate initialization of 'let' values
... now that we have an exquisitely shaved yak.

This provides a simple and uniform model for "let" constants: they are always either
immediately initialized in their declaration, or they are initialized dynamically
exactly once before any use.  

This is a simple generalization of our current model for initializers, but enables
the use of let constants in more cases in local context, e.g. patterns like this:

   let x : SomeThing

   if condition {
     x = foo()
   } else {
     x = bar()
   }
   use(x)

Previously this would have to be declared a "var" for no good reason: the value is
only ever initialized, never actually mutated.

The implementation of this is reasonably straight-forward now that the infrastructure
is in place: Sema treats 'let' constants as "settable" if they lack an initializer
(either in the declaration or in a non-PBD binding).  This exposes them as an lvalue
at the AST level.  SILGen then lowers these things to an alloc_stack, and DI enforces
the "initialization only" requirement that it already enforces for uninitialized 'let'
properties in structs/classes.



Swift SVN r23916
2014-12-13 07:17:44 +00:00
Chris Lattner
7b11ca1fb5 Increase NumVarDeclBits to cover the new bit I added.
Swift SVN r23913
2014-12-13 06:35:53 +00:00
Chris Lattner
11a84793ec Add a new bit to VarDecl to track cases where a vardecl gets an
initializer but has no "parent" PatternBindingDecl or Pattern (i.e.
paramdecls).  This is currently set on decls in the pattern of 
foreach loops and case patterns, but I'll add it to other places I
find as well.

NFC since this bit is only set and not read, just more yak shaving.


Swift SVN r23910
2014-12-13 06:25:14 +00:00
John McCall
169e4fe319 Add Builtin.UnsafeValueBuffer, which provides opaque
storage for arbitrary values.

A buffer doesn't provide any way to identify the type of
value it stores, and so it cannot be copied, moved, or
destroyed independently; thus it's not available as a
first-class type in Swift, which is why I've labelled
it Unsafe.  But it does allow an efficient means of
opaquely preserving information between two cooperating
functions.  This will be useful for the adjustments I
need to make to materializeForSet to support safe
addressors.

I considered making this a SIL type category instead,
like $@value_buffer T.  This is an attractive idea because
it's generally better-typed.  The disadvantages are that:
- it would need its own address_to_pointer equivalents and
- alloc_stack doesn't know what type will be stored in
  any particular buffer, so there still needs to be
  something opaque.

This representation is a bit gross, but it'll do.

Swift SVN r23903
2014-12-13 01:27:12 +00:00
Andrew Trick
6cc72ee21b Print SIL optimization stages. SIL debugging.
Swift SVN r23902
2014-12-12 23:57:03 +00:00
Chris Lattner
62bb07024b improve diagnostic, suggested by DaveA
Swift SVN r23890
2014-12-12 17:54:13 +00:00
Erik Eckstein
14af3a57e8 Enable elimination of dead methods which are in classes of higher visibility.
The underlying problem is that e.g. even if a method is private but its class is public, the method can be referenced from another module - from the vtable of a derived class.
So far we handled this by setting the SILLinkage of such methods according to the visibility of the class. But this prevented dead method elimination.
Now I set the SILLinkage according to the visibility of the method. This enables dead method elimination, but it requires the following:
1) Still set the linkage in llvm so that it can be referenced from outside.
2) If the method is dead and eliminated, create a stub for it (which calls swift_reportMissingMethod).



Swift SVN r23889
2014-12-12 17:35:40 +00:00
Chris Lattner
66ab73bf69 Pour some QoI love on the DI mutation diagnostics when an inout use
happens due to a method call.


Swift SVN r23884
2014-12-12 06:19:24 +00:00
Michael Gottesman
1e63e0e22d [mangle] Add support for mangling dead, owned2guaranteed, and sroa args. Wire up function sig opts.
Now all SIL function specialization passes use the new mangling infrastructure.
Lets keep it that way for future passes as well. = ).

Implements:
<rdar://problem/18831609>

Fixes:
<rdar://problem/19065735>
<rdar://problem/18906781>
<rdar://problem/18956916>

Swift SVN r23859
2014-12-11 05:51:26 +00:00