Commit Graph

465 Commits

Author SHA1 Message Date
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Joe Groff
611defcdcb Introduce -enable-guaranteed-closure-contexts staging option. 2015-12-30 20:30:38 -08:00
Jordan Rose
c40e8d9031 Add frontend option -debug-time-compilation.
This times each phase of compilation, so you can see where time is being
spent. This doesn't cover all of compilation, but does get all the major
work being done.

Note that these times are non-overlapping, and should stay that way.
If we add more timers, they should go in a different timer group, so we
don't end up double-counting.

Based on a patch by @cwillmor---thanks, Chris!

Example output, from an -Onone build using a debug compiler:

===-------------------------------------------------------------------------===
                               Swift compilation
===-------------------------------------------------------------------------===
  Total Execution Time: 8.7215 seconds (8.7779 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   2.6670 ( 30.8%)   0.0180 ( 25.3%)   2.6850 ( 30.8%)   2.7064 ( 30.8%)  Type checking / Semantic analysis
   1.9381 ( 22.4%)   0.0034 (  4.8%)   1.9415 ( 22.3%)   1.9422 ( 22.1%)  AST verification
   1.0746 ( 12.4%)   0.0089 ( 12.5%)   1.0834 ( 12.4%)   1.0837 ( 12.3%)  SILGen
   0.8468 (  9.8%)   0.0171 ( 24.0%)   0.8638 (  9.9%)   0.8885 ( 10.1%)  IRGen
   0.6595 (  7.6%)   0.0142 ( 20.0%)   0.6737 (  7.7%)   0.6739 (  7.7%)  LLVM output
   0.6449 (  7.5%)   0.0019 (  2.6%)   0.6468 (  7.4%)   0.6469 (  7.4%)  SIL verification (pre-optimization)
   0.3505 (  4.1%)   0.0023 (  3.2%)   0.3528 (  4.0%)   0.3530 (  4.0%)  SIL optimization
   0.2632 (  3.0%)   0.0005 (  0.7%)   0.2637 (  3.0%)   0.2639 (  3.0%)  SIL verification (post-optimization)
   0.0718 (  0.8%)   0.0021 (  3.0%)   0.0739 (  0.8%)   0.0804 (  0.9%)  Parsing
   0.0618 (  0.7%)   0.0010 (  1.4%)   0.0628 (  0.7%)   0.0628 (  0.7%)  LLVM optimization
   0.0484 (  0.6%)   0.0011 (  1.5%)   0.0495 (  0.6%)   0.0495 (  0.6%)  Serialization (swiftmodule)
   0.0240 (  0.3%)   0.0006 (  0.9%)   0.0246 (  0.3%)   0.0267 (  0.3%)  Serialization (swiftdoc)
   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)  Name binding
   8.6505 (100.0%)   0.0710 (100.0%)   8.7215 (100.0%)   8.7779 (100.0%)  Total
2015-12-17 15:19:09 -08:00
David Farler
101cf49880 Use -enable-resilience for IRGen super_method tests
We've already got -enable-resilience and @_fixed_layout to compare
IRGen differences when lowering super_method instructions, so nuke
the -force-resilient-super-dispatch testing flag. While
we're at it, consolidate the super tests a bit.
2015-12-16 14:01:49 -08:00
Doug Gregor
99c1af3fd1 Merge branch 'master' of github.com:/apple/swift 2015-12-14 22:06:20 -08:00
David Farler
86f815bd32 IRGen: Statically load superclass metadata for non-resilient classes
We only need to indirectly load the superclass's metadata when the
superclass is resilient. For example, we may be calling a super method
inside an extension of a class we don't own. Otherwise, we can
immediately load the statically known superclass.

Adds a testing flag to force resilient super dispatch, since the
IRGen module resilience checks aren't fully implemented yet.

SIL -> IR tests added.

rdar://problem/22749732

Also fixes rdar://problem/23884670
2015-12-14 17:37:34 -08:00
Doug Gregor
cf7ed8d600 Add -enable-swift-name-lookup-tables option to enable Swift lookup tables.
Aside from causing the tables to get built, this doesn't actually do
anything yet.
2015-12-14 15:43:30 -08:00
Doug Gregor
563bdb9156 Clang importer: remove support for implicit properties.
We decided not to support "implicit" properties, where we import
getter/setter pairs as properties. Rather, we only import a property
when there is an explicit "@property" in Objective-C. Remove the flag
and supporting code for implicit properties.
2015-12-14 14:33:07 -08:00
David Farler
a53a31cb6e SILGen: Use super_method for native non-final methods in classes
Use the `super_method` instruction for non-final `func` and `class func`
declarations in native Swift classes. Previously, we would always emit
a static `function_ref` for these, which prevents resilient dynamic
dispatch.

This is hidden behind a -use-native-super-dispatch flag while I
survey the effects on devirtualization and stack promotion. When
that's figured out, I'll add more tests and update test cases that
still assume static dispatch.

rdar://problem/22749732
2015-12-05 13:06:31 -08:00
Argyrios Kyrtzidis
8d9ef80304 [frontend] Introduce a new frontend option '-dump-api-path', which outputs a swift interface file for each compiled source file.
This is primarily intended for use with the stdlib.
2015-12-03 08:44:36 -08:00
Nadav Rotem
2a7af5fb44 Delete the flag -disable-func-sig-opts.
This commit removes the flag -disable-func-sig-opts.
2015-12-01 22:26:29 -08:00
Slava Pestov
57dd686742 Strawman @fixed_layout attribute and -{enable,disable}-resilience flags
A fixed layout type is one about which the compiler is allowed to
make certain assumptions across resilience domains. The assumptions
will be documented elsewhere, but for the purposes of this patch
series, they will include:

- the size of the type
- offsets of stored properties
- whether accessed properties are stored or computed

When -enable-resilience is passed to the frontend, all types become
resilient unless annotated with the @fixed_layout attribute.

So far, the @fixed_layout attribute only comes into play in SIL type
lowering of structs and enums, which now become address-only unless
they are @fixed_layout. For now, @fixed_layout is also allowed on
classes, but has no effect. In the future, support for less resilient
type lowering within a single resilience domain will be added, with
appropriate loads and stores in function prologs and epilogs.

Resilience is not enabled by default, which gives all types fixed
layout and matches the behavior of the compiler today. Since
we do not want the -enable-resilience flag to change the behavior
of existing compiled modules, only the currently-compiling module,
Sema adds the @fixed_layout flag to all declarations when the flag
is off. To reduce the size of .swiftmodule files, this could become
a flag on the module itself in the future.

The reasoning behind this is that the usual case is building
applications and private frameworks, where there is no need to make
anything resilient.

For the standard library, we can start out with resilience disabled,
while perfoming an audit adding @fixed_layout annotations in the
right places. Once the implementation is robust enough we can then
build the standard library with resilience enabled.
2015-11-13 13:20:49 -08:00
Nadav Rotem
2c820feb29 Revert "Remove the flag that controls signature optimization."
This reverts commit 0dd26039ce.

I did not notice that some tests depend on this flag.
2015-11-12 20:36:16 -08:00
Nadav Rotem
0dd26039ce Remove the flag that controls signature optimization. 2015-11-12 20:35:58 -08:00
Michael Gottesman
7820961891 Revert commits to fix the build.
Revert "Fix complete_decl_attribute test for @fixed_layout"
Revert "Sema: non-@objc private stored properties do not need accessors"
Revert "Sema: Access stored properties of resilient structs through accessors"
Revert "Strawman @fixed_layout attribute and -{enable,disable}-resilience flags"

This reverts commit c91c6a789e.
This reverts commit 693d3d339f.
This reverts commit 085f88f616.
This reverts commit 5d99dc9bb8.
2015-11-12 10:40:54 -08:00
Slava Pestov
5d99dc9bb8 Strawman @fixed_layout attribute and -{enable,disable}-resilience flags
A fixed layout type is one about which the compiler is allowed to
make certain assumptions across resilience domains. The assumptions
will be documented elsewhere, but for the purposes of this patch
series, they will include:

- the size of the type
- offsets of stored properties
- whether accessed properties are stored or computed

When -enable-resilience is passed to the frontend, all types become
resilient unless annotated with the @fixed_layout attribute.

So far, the @fixed_layout attribute only comes into play in SIL type
lowering of structs and enums, which now become address-only unless
they are @fixed_layout. For now, @fixed_layout is also allowed on
classes, but has no effect. In the future, support for less resilient
type lowering within a single resilience domain will be added, with
appropriate loads and stores in function prologs and epilogs.

Resilience is not enabled by default, which gives all types fixed
layout and matches the behavior of the compiler today. Since
we do not want the -enable-resilience flag to change the behavior
of existing compiled modules, only the currently-compiling module,
Sema adds the @fixed_layout flag to all declarations when the flag
is off. To reduce the size of .swiftmodule files, this could become
a flag on the module itself in the future.

The reasoning behind this is that the usual case is building
applications and private frameworks, where there is no need to make
anything resilient.

For the standard library, we can start out with resilience disabled,
while perfoming an audit adding @fixed_layout annotations in the
right places. Once the implementation is robust enough we can then
build the standard library with resilience enabled.
2015-11-12 02:30:07 -08:00
Erik Eckstein
68fa1c2c34 Support for stack promotion in IRGen.
This means: handling of alloc_ref [stack].
It can be configured with two new options. See Option/FrontendOptions.td.

As the [stack] attribute is not generated yet, there should be NFC.




Swift SVN r32929
2015-10-28 00:44:25 +00:00
Adrian Prantl
3356f7ac59 Pass the debug info settings through to Clang and ensure that compile units
created by Swift and Clang set the CU's compilation dir similarly.

rdar://problem/22692266

Swift SVN r32637
2015-10-12 22:20:58 +00:00
Doug Gregor
712796a7e2 Add a flag to enable the iterative type checker.
Swift SVN r32571
2015-10-09 17:18:48 +00:00
Joe Groff
5145a49d58 Add -disable-self-type-mangling staging option.
NFC yet.

Swift SVN r32397
2015-10-02 03:23:14 +00:00
Joe Groff
25b1110f5b Remove -enable-interface-type-mangling staging option.
Swift SVN r32285
2015-09-28 22:40:52 +00:00
Adrian Prantl
0acbc9bbd1 Thread -emit-verbose-sil into SILPasses, so it can be combined with
-sil-print-all & friends.

Swift SVN r32251
2015-09-25 23:46:50 +00:00
Doug Gregor
44b8d45288 Clean up inference of default arguments from imported APIs (mostly).
My temporary hackery around inferring default arguments from imported
APIs was too horrible. Make it slightly more sane by:

1) Actually marking these as default arguments in the type system,
rather than doing everything outside of the type system. This is a
step closer to what we would really do, if we go in this
direction. Put it behind the new -frontend flag
-enable-infer-default-arguments.

2) Only inferring a default argument from option sets and from
explicitly "nullable" parameters, as stated in the (Objective-)C API
or API notes. This eliminates a pile of spurious, non-sensical "=
nil"'s in the resulting output.

Note that there is one ugly tweak to the overloading rules to prefer
declarations with fewer defaulted arguments. This is a bad
implementation of what is probably a reasonable rule (prefer to bind
fewer default arguments), which intentionally only kicks in when we're
dealing with imported APIs that have default arguments.

Swift SVN r32078
2015-09-18 21:50:59 +00:00
Michael Gottesman
d6cdce1013 Adjust to InputArgList being a move-only type
Swift SVN r31800
2015-09-09 04:37:17 +00:00
Argyrios Kyrtzidis
1d5e9e0acd [FixCode] Introduce '-fixit-all' option that, when -fixit-code is enabled, applies all fixits from diagnostics without any filtering.
Swift SVN r31772
2015-09-08 18:30:49 +00:00
Jordan Rose
6e8140b871 Handle debug-crash options in separate functions.
...so they show up in stack traces.

Swift SVN r31592
2015-09-01 00:22:29 +00:00
Doug Gregor
561d5fd4a9 Add an opt-in warning to complain about needless words in declarations.
The new option -Womit-needless-words finds places where names are
redundant with type information, producing warnings and Fix-Its to
shorten the names. Part of rdar://problem/22232287, to help bring
the same heuristics we're applying in the Clang importer to the user's
Swift code.

Swift SVN r31234
2015-08-13 23:39:35 +00:00
Doug Gregor
284d8e52cf Introduce an option to omit needless words when importing from Clang.
The -enable-omit-needless-words option attempts to omit needless words
from method names imported from Clang. Broadly speaking, a word is
needless if it merely restates the type of the corresponding parameter,
using reverse camel-case matching of the type name to the
function/parameter name. The word "With" is also considered needless
if whether follows it is needless, e.g.,

  func copyWithZone(zone: NSZone)

gets reduced to

  func copy(zone: NSZone)

because "Zone" merely restates type information and the remaining,
trailing "With" is also needless.

There are some special type naming rules for builtin Objective-C types,
e.g.,

  id -> "Object"
  SEL -> "Selector"
  Block pointer types -> "Block"

as well as some very-Cocoa-specific matching rules, e.g., the type
"IndexSet" matches the name "Indexes" or "Indices".

Expect a lot of churn with these heuristics; this is part of
rdar://problem/22232287.

Swift SVN r31178
2015-08-12 18:21:45 +00:00
Chris Lattner
0001dc27bb remove support for the experiemental "character literals" feature.
Swift SVN r30509
2015-07-22 22:35:19 +00:00
Jordan Rose
d609aa461d Always serialize absolute search paths.
...and always serialize -working-directory for Clang. (But allow it to be
overridden by a later -Xcc -working-directory.)

Not having this has caused plenty of headaches for the debugger, which is the
primary client of this information. We can still get into bad situations with
search paths that don't exist at all (say, when a built framework is transferred
to another computer), but at least we won't fall over in multi-project workspaces.

This isn't an actual command-line option for a few reasons:

- SourceKit is still using frontend options directly, and they'll need something
  like this to fix rdar://problem/21912068.
- We might want to be more formal about passing this to Clang.
- I don't actually like the existence of such an option for users.

We can revisit this later if the scales tip. Fixing the debugging issue is the
priority.

rdar://problem/21857902

Swift SVN r30500
2015-07-22 20:20:33 +00:00
Jordan Rose
fbb8d3f9a8 Add "interface hash" for improved incremental builds.
Compute the hash of all interface tokens when parsing; write the
interface hash to the swiftdeps file, or if the -dump-interface-hash
option is passed to the frontend. This hash will be used in incremental
mode to determine whether a file's interface has changed, and therefore
whether dependent files need to be rebuilt in response to the change.

Committed on ChrisW's behalf while he gets his setup unborked.

rdar://problem/15352929

Swift SVN r30477
2015-07-22 00:13:54 +00:00
Devin Coughlin
ea18bc0c0b Rename -dump-trc option to -dump-type-refinement-contexts
As Jordan notes, 'TRC' is not a commonly-known acronym for most Swift compiler developers.

Swift SVN r30414
2015-07-20 21:47:49 +00:00
Jordan Rose
0e3e08f0c6 [ClangImporter] Use Clang's -fembed-bitcode mode when under -embed-bitcode.
This should have no functionality change, but is supposed to keep us from
accidentally relying on the "full" Clang importer when in a backend job.
I tested it by archiving a little iOS app from a developer.

Unfortunately, part of the motivation here was that we'd get error messages when
we pass something Clang doesn't like, and that doesn't seem to be happening.

rdar://problem/21389553

Swift SVN r30407
2015-07-20 17:23:51 +00:00
Devin Coughlin
b427975c39 Add a -dump-trc frontend option to print the type refinement context hierarchy
This is useful for debugging and testing.

Swift SVN r30383
2015-07-19 05:53:27 +00:00
Devin Coughlin
c1caddae62 Remove experimental support for treating unavailable symbols as optional.
This has always been off by default and is a language direction we have decided not to
pursue.

Swift SVN r30355
2015-07-18 01:56:25 +00:00
Joe Groff
bc55c4ef37 ClangImporter: Remove -enable-simd-import staging option.
Swift SVN r29765
2015-06-27 18:10:25 +00:00
Joe Groff
55a830df38 ClangImporter: Remove -enable-c-function-pointers staging option.
Swift SVN r29764
2015-06-27 18:10:21 +00:00
Joe Groff
9bdac157d2 SIL: Remove EnableTypedBoxes staging option.
Swift SVN r29762
2015-06-27 18:10:12 +00:00
Dmitri Hrybenko
502d0d5120 Adjust to the new ParseArgs API
Swift SVN r29701
2015-06-25 22:01:40 +00:00
Roman Levenstein
251bda4959 Add a field to SILOption to represent the current optimization level.
The value is set based on the -O command-line option. It is generally useful if SIL optimization passes can check the current optimization level.
A couple of subsequent commits are going to make use of this information.

Swift SVN r29653
2015-06-25 02:38:02 +00:00
Joe Groff
910badfe4d SIL: Stage in a typed-boxes dialect.
When -sil-enable-typed-boxes is passed, have alloc_box and dealloc_box instructions work with box types instead of NativeObject.

Swift SVN r29511
2015-06-19 16:39:04 +00:00
Jordan Rose
c516ef9223 [IRGen] Remove unnecessary IRGenOptions flag HasUnderlyingModule.
The test that it's guarding is cheap enough to do all the time, and we
don't have any interesting configurations where it's not set any more.

Swift SVN r29442
2015-06-17 04:48:09 +00:00
Doug Gregor
c8e3438f32 Add frontend option -disable-autolink-framework <framework>
This frontend option allows one to turn off autolinking to the
specified framework. This general capability is motivated by
rdar://problem/21246363, where we need to turn off some autolinking in
our overlays due to internal vs. public SDK differences.

Swift SVN r29393
2015-06-15 23:43:33 +00:00
Erik Eckstein
1aa561a1c8 Cleanup internal options in SIL pass manager.
I was always confused by the inconsistency of -sil-print-all and the other -sil-print options.
So I thought it would be a good idea to make -sil-print-all also an llvm option.
Together with some other internal options which are only used in the pass manager.



Swift SVN r29365
2015-06-12 13:37:00 +00:00
Slava Pestov
0c88c13c0d IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag
The last remaining case was apparently @objc generic classes, which
seem to work now.

Also nuke the IRGen/unimplemented_objc_generic_class.swift test,
this is now implemented and we have other tests that test this
functionality.

Swift SVN r29260
2015-06-03 00:01:29 +00:00
Ted Kremenek
dad92b0084 Revert "IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag"
Speculatively reverting because the iOS bots are broken.

Swift SVN r29145
2015-05-29 14:11:25 +00:00
Slava Pestov
9da369b5ba IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag
The last remaining case was apparently @objc generic classes, which
seem to work now.

Also nuke the IRGen/unimplemented_objc_generic_class.swift test,
this is now implemented and we have other tests that test this
functionality.

Swift SVN r29138
2015-05-29 06:19:06 +00:00
Dave Abrahams
d65f696344 Kill off [_]RawOptionSetType
Now that we are using OptionSetType for option sets, all the support for
doing things the old way can die.

Note: the fix-it that used to apply to RawOptionSetType, it seemed to me,
should still apply to OptionSetType, so I switched it over instead of
removing it.

Swift SVN r29066
2015-05-27 15:55:54 +00:00
David Farler
5dbc33f8ac Don't crash the frontend if a bad target is given
Provide a chance to emit a diagnostic instead.

rdar://problem/20931800

Swift SVN r28940
2015-05-23 00:58:05 +00:00
Slava Pestov
fd256e70e3 EmitGuaranteedSelf is always on now
NFC except for removal of flag

Swift SVN r28427
2015-05-11 18:21:37 +00:00