Commit Graph

2543 Commits

Author SHA1 Message Date
Joe Groff
78d75428d6 SILGen: Lower key path subscript indexes.
And fill out SIL support for parsing, printing, and serializing key path
patterns with captured indexes.
2017-09-15 10:00:32 -07:00
swift-ci
546836ceff Merge remote-tracking branch 'origin/master' into master-next 2017-09-11 15:08:53 -07:00
Roman Levenstein
74908ce818 Create utility functions for mapping between the numeric opcode of a SILValue/SILInstruction and its mnemonic name
Use it for the stats collection, but also for SIL printing.
2017-09-10 21:47:55 -07:00
Roman Levenstein
f0a39e9e14 Add support for collecting various SIL optimizer counters
This patch implements collection and dumping of statistics about SILModules, SILFunctions and memory consumption during the execution of SIL optimization pipelines.

The following statistics can be collected:
  *  For SILFunctions: the number of SIL basic blocks, the number of SIL instructions, the number of SIL instructions of a specific kind, duration of a pass
  *  For SILModules: the number of SIL basic blocks, the number of SIL instructions, the number of SIL instructions of a specific kind, the number of SILFunctions, the amount of memory used by the compiler, duration of a pass

By default, any collection of statistics is disabled to avoid affecting compile times.

One can enable the collection of statistics and dumping of these statistics for the whole SILModule and/or for SILFunctions.

To reduce the amount of produced data, one can set thresholds in such a way that changes in the statistics are only reported if the delta between the old and the new values are at least X%. The deltas are computed as using the following formula:

   Delta = (NewValue - OldValue) / OldValue

Thresholds provide a simple way to perform a simple filtering of the collected statistics during the compilation. But if there is a need for a more complex analysis of collected data (e.g. aggregation by a pipeline stage or by the type of a transformation), it is often better to dump as much data as possible into a file using e.g. -sil-stats-dump-all -sil-stats-modules -sil-stats-functions and then e.g. use the helper scripts to store the collected data into a database and then perform complex queries on it. Many kinds of analysis can be then formulated pretty easily as SQL queries.
2017-09-10 21:47:55 -07:00
Andrew Trick
cc790a7fbd Comment. Fix the description of unconditional_checked_cast side effects. 2017-09-10 19:53:37 -07:00
Andrew Trick
443e244d37 [sil-opaque-values] NFC, Allow SIL conventions to be set within SILBuilder.
This keeps the `create*` API simple for *normal* users and forces
AddressLowering to declare conventions when creating a builder.
2017-09-10 18:11:05 -07:00
Davide Italiano
d98a15875d [SILValue] Prefer const_cast<> to C-style cast.
Prevents a quite spammy warning with new versions of clang
(in the particular case, trunk as per today).
2017-09-09 16:59:16 -07:00
swift-ci
4ea8c5f516 Merge remote-tracking branch 'origin/master' into master-next 2017-09-08 22:49:02 -07:00
Michael Gottesman
fc1a639a9e [mandatory-inline] Move the creation of the inliner and bailing upon knowing that inlining will fail, before any side-effect having work occurs.
rdar://31521023
2017-09-08 22:18:07 -07:00
swift-ci
3706b8fa80 Merge remote-tracking branch 'origin/master' into master-next 2017-09-07 17:28:54 -07:00
Michael Gottesman
9e8a712dfa Merge pull request #11808 from gottesmm/pr-ca42038a7bd82a50a8617ca95957e9556d3e8467
[di] Update definite_initialization for ownership.
2017-09-07 17:25:09 -07:00
Bob Wilson
acf22554f3 Declare DomTreeBuilder template instantiations in Dominance.h
This is a follow-up to https://github.com/apple/swift/pull/11075.
2017-09-07 16:08:48 -07:00
Michael Gottesman
4c087097f3 [di] Update definite_initialization for ownership.
rdar://31521023
2017-09-07 15:23:22 -07:00
swift-ci
0c9e8d82c5 Merge remote-tracking branch 'origin/master' into master-next 2017-09-07 08:28:59 -07:00
Arnold Schwaighofer
3edcd3008d SILBasicBlock: Add moveTo method 2017-09-06 07:24:19 -07:00
Arnold Schwaighofer
1bc5fb193b SIL: Add a utility function to SILBasicBlock to delete its instructions 2017-09-06 07:24:19 -07:00
swift-ci
dcec858bee Merge remote-tracking branch 'origin/master' into master-next 2017-08-28 14:28:57 -07:00
Jordan Rose
449cd98997 Excise "Accessibility" from the compiler (3/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

Rename AccessibilityAttr to AccessControlAttr and
SetterAccessibilityAttr to SetterAccessAttr, then track down the last
few uses of "accessibility" that don't have to do with
NSAccessibility. (I left the SourceKit XPC API alone because that's
supposed to be more stable.)
2017-08-28 13:27:59 -07:00
swift-ci
bb61aaa47a Merge remote-tracking branch 'origin/master' into master-next 2017-08-25 14:29:05 -07:00
Joe Shajrawi
8911d9a0fd Merge pull request #11520 from shajrawi/reduce_explosion
Reduce expansion of large types in the optimizer
2017-08-25 14:19:16 -07:00
Joe Shajrawi
570a82aea5 Reduce expansion of large types in the optimizer 2017-08-25 13:56:26 -07:00
swift-ci
aa700a9ca8 Merge remote-tracking branch 'origin/master' into master-next 2017-08-23 10:29:34 -07:00
Erik Eckstein
9c6fe76927 SIL, IRGen: add instructions "object" and "global_value” to support statically initialized objects.
This commit contains:
-) adding the new instructions + infrastructure, like parsing, printing, etc.
-) support in IRGen to generate global object-variables (i.e. "heap" objects) which are statically initialized in the data section.
-) IRGen for global_value which lazily initializes the object header and returns a reference to the object.

For details see the documentation of the new instructions in SIL.rst.
2017-08-23 09:15:49 -07:00
Erik Eckstein
1ab582e121 SIL: A new representation of static initializers for global variables.
Static initializers are now represented by a list of literal and aggregate instructions in a SILGlobalVariable.
For details see SIL.rst.

This representation is cleaner than what we did so far (point to the initializer function and do some pattern matching).

One implication of that change is that now (a subset of) instructions not necessarily have a parent function.
Regarding the generated code it's a NFC.
Also the swift module format didn't change because so far we don't serializer global variables.
2017-08-23 09:15:01 -07:00
Erik Eckstein
24b684b22d SILPrinter: allow also basic blocks to be a context.
Plus a small refactoring to simplify the code: remove the inner SILPrintFunctionContext struct
2017-08-23 09:15:00 -07:00
Erik Eckstein
020a283bbb SIL: Let the OpenedArchetypesTracker be constructed with a null SILFunction.
NFC
2017-08-23 09:15:00 -07:00
Erik Eckstein
c6a466ca40 SIL: allow some literal and aggregate instructions to be constructed without a function context
just refactoring, NFC
2017-08-23 09:15:00 -07:00
swift-ci
1134ff2ab0 Merge remote-tracking branch 'origin/master' into master-next 2017-08-21 12:09:03 -07:00
David Zarzycki
9b836bc762 [SIL] NFC: Fix isa/dyn_cast for three Unmanaged.*ValueInsts 2017-08-21 12:30:58 -04:00
David Zarzycki
5d9be1a70a [SIL] NFC: use inheritance to simplify printing
There is no need for us to manually call the abstract base class. The
visitor pattern will do that for us.

Also, make SILNodes.def and SILInstruction.h agree about the parent type
of the strong pin/unpin instructions.
2017-08-21 10:11:55 -04:00
swift-ci
6e2ea84d69 Merge remote-tracking branch 'origin/master' into master-next 2017-08-18 20:49:17 -07:00
Andrew Trick
5aac427ee0 SIL Ownership: Remove consumptionKind from SIL unconditional cast and related logic.
Remove the cast consumption kind from all unconditional casts. It
doesn't make sense for unconditional casts, complicates SIL ownership,
and wasn't fully supported for all variants. Copies should be
explicit.
2017-08-18 20:44:54 -07:00
John McCall
a5d328690d PointerLikeTypeTraits is now a struct, not a class.
We compile with a pedantic warning that complains about these things,
and the massive flood of warnings is actually causing problems for the
build infrastructure.
2017-08-17 17:01:17 -04:00
Slava Pestov
a7ff2d2ddc SIL: Refactor SILVTable::getImplementation() into getEntry()
This will allow IRGen to recover the entry kind when emitting
class metadata.
2017-08-14 22:45:59 -04:00
Slava Pestov
556d35d9b1 SIL: Record whether vtable entries are inherited or overridden
Consider a class hierarchy like the following:

class Base {
  func m1() {}
  func m2() {}
}

class Derived : Base {
  override func m2() {}
  func m3() {}
}

The SIL vtable for 'Derived' now records that the entry for m1
is inherited, the entry for m2 is an override, and the entry
for m3 is a new entry:

sil_vtable Derived {
  #Base.m1!1: (Base) -> () -> () : _T01a4BaseC2m1yyF [inherited]
  #Base.m2!1: (Base) -> () -> () : _T01a7DerivedC2m2yyF [override]
  #Derived.m3!1: (Derived) -> () -> () : _T01a7DerivedC2m3yyF
}

This additional information will allow IRGen to emit the vtable
for Derived resiliently, without referencing the symbol for
the inherited method m1() directly.
2017-08-14 19:50:34 -04:00
Roman Levenstein
bae290cdab Always put SILFunctions into a zombie list, when they are erased.
This removes the function body, but preserves the SILFunction object, which may be still referenced by different kinds of meta-information e.g. debug info for inlined functions, generic specializations information, etc.

Doing this unconditionally simplifies the code and makes it less error-prone to reference SILFunctions from any kind of meta-information. It just works. No need to set any special flags, etc.
2017-08-11 11:14:41 -07:00
John McCall
1c6bf687f0 Make SILWitnessVisitor traffic in SILDeclRef instead of Decl. NFC. 2017-08-10 23:25:15 -04:00
John McCall
bd8246351e Add an AST-level abstraction for representing an abstract associated
type or conformance requirement.  NFC.
2017-08-10 20:15:20 -04:00
Roman Levenstein
a920e32e54 Allocate GenericSpecializationInformation using SILModule's memory allocator. 2017-08-06 23:04:46 -07:00
Roman Levenstein
6b5aced3b9 Make it possible to mark SILFunction as referenced by metainformation
This marker can be used e.g. when a function is referenced from the generic specialization information (or any other kind of metadata) to indicate that this SIL function should not be completely eliminated by the dead function elimination pass even if it is not referenced by any function_ref instruction anymore. Such a function will be preserved in a zombie list instead if it needs to be eliminated.
2017-08-06 12:51:49 -07:00
Roman Levenstein
a73fbdb3fe Define a GenericSpecializationInformation class which can be used to track the history of generic specializations
GenericSpecializationInformation contains information regarding how a given specialized function was created, e.g. which caller function triggered this specialization, which substitutions were used, etc. Provide some debugging flags to dump the collected specialization information.

The information about generic specializations is referenced by the specialized functions and by call-sites originating from specialized functions.

This information can be created/used by the generic specializer to detect generic call-sites whose specialization would result in non-terminating sequence of subsequent generic specializations.
2017-08-06 12:51:49 -07:00
swift-ci
a561c3c4e4 Merge remote-tracking branch 'origin/master' into master-next 2017-08-02 17:29:58 -07:00
Andrew Trick
314d48f055 Fix ownership of UnconditionalCheckedCastValue. 2017-08-02 16:26:41 -07:00
Chris Bieneman
9c35042ae6 Merge remote-tracking branch 'origin/master' into master-next 2017-07-28 09:51:36 -07:00
swift-ci
781b133514 Merge pull request #11230 from gottesmm/rdar33502257 2017-07-27 21:33:14 -07:00
Michael Gottesman
81914b9234 When creating destroys for addresses passed into a partial apply, first move the values into a stack location with a live range that is guaranteed to be larger than the partial apply's live range.
Otherwise, we may insert destroy_addrs on alloc_stack whose lifetimes have
ended.

rdar://33502257
2017-07-27 20:48:47 -07:00
Andrew Trick
9a770a9528 [sil-opaque-values] OwnershipVerifier support. 2017-07-27 11:35:16 -07:00
Andrew Trick
f5d0ce87be Remove redundant method getOperandIndexOfFirstArgument(). 2017-07-27 10:58:53 -07:00
swift-ci
a928ea73bd Merge remote-tracking branch 'origin/master' into master-next 2017-07-25 11:50:04 -07:00
Joe Groff
aca4caea8d Merge pull request #11144 from jckarter/dynamic-required-init-override
SILGen: Fix override handling when a dynamic init is also required.
2017-07-25 11:43:45 -07:00