Commit Graph

118 Commits

Author SHA1 Message Date
eeckstein
8961bf1d66 Revert "Enable ExistentialSpecializer by default" 2019-05-09 13:25:51 -07:00
Raj Barik
1d152fe682 Merge pull request #19820 from rajbarik/raj-es-enable
Enable ExistentialSpecializer by default
2019-05-06 13:03:28 -07:00
Michael Gottesman
1defc94966 [ownership] Add a frontend option to strip ownership after serialization.
I am going to use this to ensure some end-to-end tests that do not inline from
the stdlib will work after flipping the switch and stripping ownership after
serialization.
2019-04-13 20:53:42 -07:00
Michael Gottesman
f699e0e8d0 [ownership] Remove the -enable-mandatory-semantic-arc-opts flag now that it is enabled by default. 2019-03-27 18:33:21 -07:00
Michael Gottesman
f854547c55 [ownership] Enable ownership verification by default.
I also removed the -verify-sil-ownership flag in favor of a disable flag
-disable-sil-ownership-verifier. I used this on only two tests that still need
work to get them to pass with ownership, but whose problems are well understood,
small corner cases. I am going to fix them in follow on commits. I detail them
below:

1. SILOptimizer/definite_init_inout_super_init.swift. This is a test case where
DI is supposed to error. The only problem is that we crash before we error since
the code emitting by SILGen to trigger this error does not pass ownership
invariants. I have spoken with JoeG about this and he suggested that I fix this
earlier in the compiler. Since we do not run the ownership verifier without
asserts enabled, this should not affect compiler users. Given that it has
triggered DI errors previously I think it is safe to disable ownership here.

2. PrintAsObjC/extensions.swift. In this case, the signature generated by type
lowering for one of the thunks here uses an unsafe +0 return value instead of
doing an autorelease return. The ownership checker rightly flags this leak. This
is going to require either an AST level change or a change to TypeLowering. I
think it is safe to turn this off since it is such a corner case that it was
found by a test that has nothing to do with it.

rdar://43398898
2019-03-25 00:11:52 -07:00
Michael Gottesman
0dfaa19f9f [ownership] Rename enable-sil-ownership => verify-sil-ownership.
I have been meaning to do this change for a minute, but kept on putting it off.
This describes what is actually happening and is a better name for the option.
2019-03-18 01:31:44 -07:00
Michael Gottesman
04ec2c86b2 [ownership] Move OME out of the diagnostics pipeline behind a flag.
Once the flag is flipped, ownership stripping will no longer be done in the
diagnostics pipeline. Instead what will happen is that:

* Onone: At -Onone, we run the entire diagnostics pipeline with ownership
enabled and do not strip ownership until after we serialize in the Onone
"optimization" pass pipeline plan.

* -O: At -O, to temporarily work around serialization issues with transparent
functions, we strip ownership from all but transparent functions at the
beginning of the performance pipeline, serialize, and then strip ownership from
transparent functions. For this to work, I needed to make sure that the
performance pipeline passes that do not support ownership SIL, just skip such
functions. So the transparent functions will arrive (mostly) untouched in
serialized SIL and the rest of the pipeline will optimize non-transparent
functions as they should.

The key thing about the -O change is that it /should/ be performance neutral
since after we serialize we re-run the entire pipeline so we can optimize
semantic functions that we only can inline after we serialize.
2019-02-02 22:58:39 -08:00
Michael Gottesman
9dc8bbb866 [ownership] Eliminate -assume-parsing-unqualified-ownership-sil now that it is a no-op. 2018-12-19 12:54:13 -08:00
Harlan Haskins
2e50a431b1 Merge pull request #20986 from harlanhaskins/clogged-pipes
[SILOptimizer] Stop optimization after serialization if only emitting a module
2018-12-06 15:49:11 -08:00
Harlan Haskins
b137928ff5 [SILOptimizer] Add flag to stop optimization after serialization 2018-12-04 16:44:01 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Raj Barik
bb34051850 Enable ExistentialSpecializer by default 2018-10-10 10:15:35 -07:00
Raj Barik
89d31be7a5 ExistentialSpecializer Pass (without SILCombine/ConcreteType Propagation) 2018-09-25 14:52:00 -07:00
Michael Gottesman
53403e29ac [+0-all-args] Remove the SILOption EnableGuaranteedNormalArguments and minimally simplify code.
I made this change by removing the SILOption and then doing a compile, fix loop. I
purposely did not move around the code to make the refactoring really easy to
see.
2018-07-29 20:15:51 -07:00
Slava Pestov
a3ab7561c5 SIL: Move LinkingMode to SILModule 2018-04-17 15:13:35 -07:00
Slava Pestov
1bc56840e1 SIL: Remove unused LinkingMode::LinkNone 2018-04-17 15:10:41 -07:00
Slava Pestov
45f3f013b0 Remove -disable-sil-linking frontend flag 2018-04-17 15:10:22 -07:00
Mark Lacey
21134efd22 Revert "IRGen: Deserialize SIL witness tables and shared-linkage definitions by need." 2018-03-30 22:14:13 -07:00
Joe Groff
ae2d2973d1 IRGen: Deserialize SIL witness tables and shared-linkage definitions by need.
Code may end up indirectly using a witness table for a Clang-imported type by inlining code that used the conformance from another module, in which case we need to ensure we have a local definition at hand in the inlining module so we can have something to link against independently. This needs to be fixed from both sides:

- During serialization, serialize not only witness tables from the current module, but from Clang-imported modules too, so that their definitions can be used by other modules that inline code from the current module
- During IRGen, when we emit a reference to a SILWitnessTable or SILFunction declaration with shared linkage, attempt to deserialize the definition on demand

Fixes rdar://problem/38687726.
2018-03-30 11:12:58 -07:00
Michael Gottesman
e567bc9028 [+0-all-args] Enable +0 normal arguments.
rdar://34222540
2018-03-19 20:25:31 -07:00
Andrew Trick
def6d24237 Add -verify-exclusivity option (off by default) 2018-02-15 11:26:54 -08:00
David Ungar
51d3165874 NFC: Clarifying uses of NumThreads.
Add hasMultipleGMs predicate to SILOptions.
Rename parameters to TBD file handling to better reflect abstraction boundary.

fix
2017-12-16 13:58:01 -08:00
Arnold Schwaighofer
3e04f21a41 SIL: Remove EnableGuaranteedClosureContext now that it is the default 2017-11-27 07:25:03 -08:00
Michael Gottesman
cb4e085e28 [all-+0] Add new field to SILOptions.EnableGuaranteedNormalArguments and use it to trigger +0 normal arguments.
This enables one to control via SILOptions whether or not normal arguments are
emitted as guaranteed. In a subsequent commit, I am going to add support for
triggering this via a frontend option.

I also got rid of the default Owned argument to DefaultConvention. Now
everywhere we create a DefaultConvention, we must be explicit about our normal
parameter convention.

rdar://34222540
2017-11-19 12:38:07 -08:00
Arnold Schwaighofer
0971d82f70 SILGen: Remaining fixes for @callee_guaranteed closures and enable it
- Fix block to func reabstraction thunks block argument handling
- Forward cast ownership
- Fix applyPartiallyAppliedSuperMethod ownership for @callee_guaranteed closures
- Avoid a copy in buildBlockToFuncThunkBody
- Update tests for callee_guaranteed closures

SR-5441
rdar://33255593
2017-11-15 19:46:08 -08:00
Erik Eckstein
90c21be191 Unify the implementation of optimization mode in various option classes.
This commit is mostly refactoring.

*) Introduce a new OptimizationMode enum and use that in SILOptions and IRGenOptions
*) Allow the optimization mode also be specified for specific SILFunctions. This is not used in this commit yet and thus still a NFC.

Also, fixes a minor bug: we didn’t run mandatory IRGen passes for functions with @_semantics("optimize.sil.never")
2017-11-14 11:25:02 -08:00
Arnold Schwaighofer
56a1663c98 Merge pull request #12658 from rajbarik/master
Improve Osize
2017-10-30 07:23:49 -07:00
Raj Barik
c0b7cf0ff5 Expose UnrollThreshold and Inline_Benefit_reduction in the command line for automatic code size tuning 2017-10-27 10:30:23 -07:00
Adam Nemet
66085a8aef Save optimization remarks in an external YAML file
This brings the capability from clang to save remarks in an external YAML files.
YAML files can be viewed with tools like the opt-viewer.

Saving the remarks is activated with the new option -save-optimization-record.

Similarly to -emit-tbd, I've only added support for single-compile mode for now.
In this case the default filename is determined by
getOutputFilenameFromPathArgOrAsTopLevel, i.e. unless explicitly specified
with -save-optimization-record-path, the file is placed in the directory of the
main output file as <modulename>.opt.yaml.
2017-10-27 10:14:27 -07:00
Roman Levenstein
5047e1b475 Enable the serialization of sil_vtables by default and completely remove the -sil-serialize-vtables option
Only sil_vtables of public classes with fixed layout are serialized.
2017-10-21 11:36:12 -07:00
Roman Levenstein
48d9b99675 Remove -sil-serialize-witness-tables flag completely
The functionality is always enabled now and there is no need to have a dedicated flag for it.
2017-10-20 19:45:29 -07:00
Roman Levenstein
d484a9cdda Enable serialization of witness tables by default
Now that we remove the [serialized] flag from functions after their early serialization, we can run another round of optimizations on them. Due to this change, it should be OK to serialize witness tables now because marking the witness methods [serialized] does not affect how well they can be optimized.
2017-10-17 15:24:40 -07:00
Roman Levenstein
5e67f755e0 Remove the -sil-serialize-all option 2017-10-04 14:20:53 -07:00
Roman Levenstein
e0d3175db4 Add a new option -sil-serialize-vtables
This option needs to be used if vtables should be serialized. The primary use-case for this option is when you build the standard library.
2017-10-02 14:34:14 -07:00
Vedant Kumar
1621facc6c [SwiftPGO] Add driver support for -profile-use=<path>
This option tells the compiler where to find a profdata file. The
information in this file enables PGO. For more information about the PGO
infrastructure, look for the -profile-generate option and for the
llvm-profdata tool [1].

[1] http://llvm.org/docs/CommandGuide/llvm-profdata.html
2017-09-26 10:52:08 -07:00
Arnold Schwaighofer
9535f8be32 Frontend: Add an Osize optimization option
This adds an size optimization mode ("Osize") which intends to enable some
optimization but targets mainly reduced code size compared to the regular
optimized mode ("O").

rdar://33075751
2017-08-17 14:57:21 -07:00
George Karpenkov
efe143c2f4 Adding support for -sanitize=fuzzer flag (#11381)
Similarly to Clang, the flag enables coverage instrumentation, and links
`libLLVMFuzzer.a` to the produced binary.
Additionally, this change affects the driver logic, and enables the
concurrent usage of multiple sanitizers.
2017-08-07 18:16:51 -07:00
Joe Shajrawi
84994dc786 Enable large loadable types by default 2017-08-03 11:45:28 -07:00
Roman Levenstein
2f920c4ad2 Add a new frontend option -sil-serialize-witness-tables to force serialization of SIL witness tables
This option is supposed to be used only for compiling overlays. User code should never be compiled with this option.
2017-06-19 19:49:01 -07:00
Roman Levenstein
2a10d8692b Clean-up the code that stored and passes the SILSerializeAll flag around.
- SILSerializeAll flag is now stored in the SILOptions and passed around as part of it
- Explicit SILSerializeAll/wholeModuleSerialized/makeModuleFragile API parameters are removed in many places
2017-06-16 17:50:33 -07:00
Arnold Schwaighofer
ca63326e1b Delete unused existential value witnesses from the old existential
implementation

And remove the SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS flag.
2017-06-02 14:34:41 -07:00
Andrew Trick
25d17e9933 Enable enforce-exclusivity=checked at -Onone.
This enables dynamic checking at -Onone.

Static checking is enabled by default regardless of optimizations.

SILGen only emits dynamic markers at -Onone, or when explicitly requested with
-enforce-exclusivity=checked|dynamic.

All access markers are stripped at the start of the optimization pipeline
regardless of optimization level or command line flags.
2017-05-31 21:43:00 -07:00
Joe Shajrawi
edea7d04b3 Add a flag (false by default) for large loadable types pass 2017-05-22 14:25:25 -07:00
Devin Coughlin
f239ae2ad7 [Exclusivity] Suggest Fix-Its to replace swap() with swapAt()
Extend the static diagnostics for exclusivity violations to suggest replacing

  swap(&collection[index1], &collection[index2]

with

  collection.swapAt(index1, index2).

when 'collection' is a MutableCollection.

To do so, repurpose some vestigial code that was previously used to suppress all
exclusivity diagnostics for calls to swap() and add some additional syntactic,
semantic,  and textual pattern matching.

rdar://problem/31916085
2017-05-17 17:48:58 -07:00
Devin Coughlin
d54d9b1cfe [SE-0176] Enable static enforcement of exclusive access by default
Turn on static checks for the already-accepted portions of SE-0176: Enforce
Exclusive Access to Memory.

This includes static checking for overlapping inout parameter accesses
(and inout-to-pointer accesses).

Static violations are warnings in Swift 3 compatibility mode and errors
in Swift 4 mode.

Dynamic enforcement is not enabled by default.

This does not add static checking for the Non-Escaping Recursion
Restriction rule nor the Non-Escaping Parameter Call Restriction rule. These
are revisions to SE-0176 still under review.
2017-05-15 10:35:11 -07:00
Andrew Trick
48ecd6d563 [Exclusivity] Enable SILGen access marker emission by default.
This has no measurable effect on benchmarks and does not affect
standard library compile time.
2017-04-24 08:32:15 -07:00
Devin Coughlin
ae3b13ed2d [Exclusivity] Put suppression for free function swap() behind a flag
And leave suppression off by default for now. We'll use this to evaluate
how often swap() causes exclusivity conflicts to be reported.
2017-04-18 17:21:53 -07:00
Devin Coughlin
df2239e8a5 [SILGen] Disable emitAssignLValueToLValue peephole when enforcing exclusivity
The peephole causes the the formal access to the source and destination to
overlap. This results in unwanted exclusive access conflicts when assigning
from one struct stored property to another.

At John's suggestion I've added an isObviouslyNonConflicting() helper
method on LValue that tells when when it is safe to use the peephole
even when exclusivity enforcement enabled. For now, the helper is toothless. It
can be extended to claw back some of the peephole opportunities.
2017-04-13 13:51:24 -07:00
Michael Gottesman
5e278fdf67 [semantic-arc-opts] Create a new pass called semantic arc opts.
I am going to run it very early and use it to ensure that extra copies due to my
refactoring of SILGenPattern do not cause COW copies to be introduced.

For now, it does a very simple optimization, namely, it eliminates a copy_value,
with only a destroy_value user on a guaranteed parameter.

It is now disabled behind a flag.
2017-04-05 16:16:57 -07:00
David Farler
65668c9d82 Cache Code Completion results from PCH files
- Add CompilerInvocation::getPCHHash
  This will be used when creating a unique filename for a persistent
  precompiled bridging header.

- Automatically generate and use a precompiled briding header
  When we're given both -import-objc-header and -pch-output-dir
  arguments, we will try to:
  - Validate what we think the PCH filename should be for the bridging
    header, based on the Swift PCH hash and the clang module hash.
    - If we're successful, we'll just use it.
    - If it's out of date or something else is wrong, we'll try to
      emit it.
  - This gives us a single filename which we can `stat` to check for the
    validity of our code completion cache, which is keyed off of module
    name, module filename, and module file age.

- Cache code completion results from imported modules
  If we just have a single .PCH file imported, we can use that file as
  part of the key used to cache declarations in a module.  Because
  multiple files can contribute to the __ObjC module, we've always given
  it the phony filename "<imports>", which never exists, so `stat`-ing it
  always fails and we never cache declarations in it.

  This is extremely problematic for projects with huge bridging headers.
  In the case where we have a single PCH import, this can bring warm code
  completion times down to about 500ms from over 2-3s, so it can provide a
  nice performance win for IDEs.

- Add a new test that performs two code-completion requests with a bridging header.
- Add some -pch-output-dir flags to existing SourceKit tests that import a bridging
  header.

rdar://problem/31198982
2017-04-04 20:44:33 -07:00