Commit Graph

884 Commits

Author SHA1 Message Date
Varun Gandhi
96604470ae [AST] Add printing for Clang function types in the AST. 2020-01-06 13:00:04 -08:00
Adrian Prantl
046c849949 Add an option to disable ClangImporter imports form source.
This is primarily meant to used for testing LLDB's DWARFImporterDelegate,
however, this could become the default option for LLDB once
DWARFImporterDelegate is sufficiently mature.

<rdar://problem/57880844>
2019-12-16 13:40:21 -08:00
Brent Royal-Gordon
63ec1cf5af Introduce a separate #filePath, remove -pound-file
This makes the path behavior more first-class. The feature is now hidden behind an experimental flag, -enable-experimental-concise-pound-file.
2019-12-04 16:35:13 -08:00
Brent Royal-Gordon
789d38eb04 Control #file behavior with a command line option 2019-12-04 16:33:25 -08:00
David Ungar
380d0d973e Merge pull request #28563 from davidungar/renaming-dependencies
[Incremental compilation] Rename "experimental dependencies" to "fine-grained dependencies"
2019-12-04 10:47:24 -08:00
David Ungar
6a6e9357ef Change "experimental" to "fine-grained". 2019-12-04 08:50:44 -08:00
Varun Gandhi
e7be41d0cb Merge pull request #27479 from varungandhi-apple/vg-track-clang-function-types
Track Clang function types in the AST
2019-12-04 08:47:35 -08:00
Erik Eckstein
a5397b434c Cross module optimization
This is a first version of cross module optimization (CMO).

The basic idea for CMO is to use the existing library evolution compiler features, but in an automated way. A new SIL module pass "annotates" functions and types with @inlinable and @usableFromInline. This results in functions being serialized into the swiftmodule file and thus available for optimizations in client modules.
The annotation is done with a worklist-algorithm, starting from public functions and continuing with entities which are used from already selected functions. A heuristic performs a preselection on which functions to consider - currently just generic functions are selected.

The serializer then writes annotated functions (including function bodies) into the swiftmodule file of the compiled module. Client modules are able to de-serialize such functions from their imported modules and use them for optimiations, like generic specialization.

The optimization is gated by a new compiler option -cross-module-optimization (also available in the swift driver).
By default this option is off. Without turning the option on, this change is (almost) a NFC.

rdar://problem/22591518
2019-12-03 14:37:01 +01:00
Varun Gandhi
196f358dec [AST] Add ClangTypeConverter, computing C types for FunctionTypes.
Note: The change in ASTBuilder::createFunctionType is functionally minor,
but we need the FunctionType::Params computed _before_ the ExtInfo, so we
need to shuffle a bunch of code around.
2019-11-22 12:42:36 -08:00
Doug Gregor
ec70b62d5e Merge pull request #28107 from allevato/emit-pcm
Add driver flag to precompile Swift-compatible explicit Clang modules.
2019-11-14 10:25:53 -08:00
Dan Liew
5446d333b8 Merge pull request #28126 from danliew-apple/rdar_56346688
[Sanitizers] Add Driver/Frontend option to enable sanitizer instrumentation that supports error recovery
2019-11-13 17:19:52 -08:00
Robert Widmann
aa98f254ac Cleanup integer option parsing a bit 2019-11-13 07:37:12 -08:00
Robert Widmann
f4d333d066 Sink a bunch of semantic options into TypeCheckerOptions
Sink
- DebugConstraintSolver
- DebugConstraintSolverAttempt
- DebugConstraintSolverOnLines
- DebugGenericSignatures
- DebugForbidTypecheckPrefix
- SolverMemoryThreshold
- SolverBindingThreshold
- SolverShrinkUnsolvedThreshold
- SolverDisableShrink
- EnableOperatorDesignatedTypes
- DisableConstraintSolverPerformanceHacks
- SolverEnableOperatorDesignatedTypes
2019-11-12 22:39:49 -08:00
Doug Gregor
fb9bee7d0b Merge pull request #28173 from CodaFi/gradual-typing
[NFC] Centralize TypeChecker Flags With TypeCheckerOptions
2019-11-12 13:19:48 -08:00
Michael Gottesman
901ca16eca [frontend] Fix obvious typo.
Just found via inspection.
2019-11-12 11:48:22 -08:00
Dan Liew
63e72909b5 [Sanitizers] Add Driver/Frontend option to enable sanitizer instrumentation that supports error recovery.
The new option `-sanitize-recover=` takes a list of sanitizers that
recovery instrumentation should be enabled for. Currently we only
support it for Address Sanitizer.

If the option is not specified then the generated instrumentation does
not allow error recovery.

This option mirrors the `-fsanitize-recover=` option of Clang.

We don't enable recoverable instrumentation by default because it may
lead to code size blow up (control flow has to be resumable).

The motivation behind this change is that today, setting
`ASAN_OPTIONS=halt_on_error=0` at runtime doesn't always work. If you
compile without the `-sanitize-recover=address` option (equivalent to
the current behavior of the swift compiler) then the generated
instrumentation doesn't allow for error recovery. What this means is
that if you set `ASAN_OPTIONS=halt_on_error=0` at runtime and if an ASan
issue is caught via instrumentation then the process will always halt
regardless of how `halt_on_error` is set. However, if ASan catches an
issue via one of its interceptors (e.g. memcpy) then `the halt_on_error`
runtime option is respected.

With `-sanitize-recover=address` the generated instrumentation allows
for error recovery which means that the `halt_on_error` runtime option
is also respected when the ASan issue is caught by instrumentation.

ASan's default for `halt_on_error` is true which means this issue only
effects people who choose to not use the default behavior.

rdar://problem/56346688
2019-11-12 11:33:58 -08:00
Michael Gottesman
a02fca16e2 [ownership] Add a frontend option -disable-ossa-opts to disable ossa based opts for benchmarking purposes. 2019-11-12 10:12:45 -08:00
Robert Widmann
422bb372d3 Teach the frontend how to parse TypeCheckerOptions 2019-11-12 09:54:06 -08:00
Harlan Haskins
3745dcc3e4 [TBDGen] Match TAPI's truncation behavior for dylib versions
TAPI and the linker truncate individual version components to 255 if
they overflow, because the linker packs 3 version components into a
32-bit int. Make sure we use the same parsing routines as TAPI.

Fixes rdar://57043178
2019-11-11 15:11:19 -08:00
Tony Allevato
2c7b518460 Consolidate code that computes resource dir relative to swift executable. 2019-11-11 15:00:51 -08:00
Tony Allevato
3c45041b17 Add driver modes to emit and dump Clang precompiled modules. 2019-11-11 15:00:51 -08:00
Owen Voorhees
caa6316257 Merge pull request #28052 from owenv/educational-notes
[Diagnostics] Introduce "Educational Notes" for diagnostics
2019-11-08 13:19:44 -08:00
Xi Ge
a06824d58d ClangImporter: pass down -warnings-as-errors to clang invocation
rdar://56834891
2019-11-07 17:14:03 -08:00
Owen Voorhees
ac05a66938 [Diagnostics] Introduce "Educational Notes" for diagnostics
Educational notes are small pieces of documentation which explain a concept
relevant to some diagnostic message. If -enable-descriptive-diagnostics is
passed, they will be printed after a diagnostic message if available.

Educational notes can be found at /usr/share/doc/diagnostics in a
toolchain, and are associated with specific compiler diagnostics in
EducationalNotes.def.
2019-11-07 13:18:35 -08:00
Joe Groff
4d6392b8ad Add an option to stage in substituted type lowering for function values 2019-11-05 11:32:34 -08:00
marcrasi
513467fc92 [AutoDiff upstream] set EnableExperimentalDifferentiableProgramming bool (#28001)
I noticed that the PR introducing `EnableExperimentalDifferentiableProgramming` (https://github.com/apple/swift/pull/27446) does not actually set it. This PR sets it.
2019-11-04 22:02:33 -08:00
Hamish Knight
998434f0da Add a -disable-invalid-ephemeralness-as-error flag
Currently this does nothing, as we're warning by
default, but once we error by default, this will
downgrade the diagnostic to a warning.
2019-11-03 08:42:26 -08:00
Hamish Knight
7077a68b83 [Sema] Diagnose unsound pointer conversions
Diagnose ephemeral conversions that are passed to @_nonEphemeral
parameters. Currently, this defaults to a warning with a frontend flag
to upgrade to an error. Hopefully this will become an error by default
in a future language version.
2019-11-03 08:42:25 -08:00
Adrian Prantl
ed8294247b Add a hidden option to disable debugger shadow copies.
This option is useful to debug the compiler itself, to simulate debug info as it
would be generated when producing optimized code, but without the unpredictable
output of an optimizing debugger.
2019-10-31 17:35:16 -07:00
Pavel Yaskevich
0c1502163b Merge pull request #27781 from owenv/descriptive-diagnostics-flag
[Diagnostics] Add -enable-experimental-descriptive-diagnostics frontend flag
2019-10-18 19:53:33 -07:00
Owen Voorhees
0a84879c74 [Diagnostics] Add -enable-experimental-descriptive-diagnostics frontend flag
This flag will feature-gate work on producing more descriptive diagnostic messages.
It will remain a hidden frontend option until these improvements are ready to ship.
2019-10-18 18:13:19 -07:00
Arnold Schwaighofer
57f2f5140e Merge pull request #27697 from aschwaighofer/runtime_compat_version_dynamic_replacement_lib
Respect runtime-compatibility-version flag also for dynamic replacement compatibility library
2019-10-17 13:05:15 -07:00
Arnold Schwaighofer
390eaab723 Move common code into function 2019-10-15 10:47:35 -07:00
Arnold Schwaighofer
4d94eff93c Respect runtime-compatibility-version flag also for dynamic replacement compatibility library
rdar://56259688
2019-10-15 10:31:18 -07:00
Doug Gregor
43da5c9744 Remove dead flag disable-tsan-inout-instrumentation 2019-10-14 21:42:33 -07:00
Doug Gregor
14be78d54d Remove -(enable|disable)-function-builder-one-way-constraints
Remove the staging flags for unidirectional constraints in function
builders. We're not going back!
2019-10-14 21:22:28 -07:00
Harlan Haskins
b904133c42 [Modules] Add flag to skip non-inlinable function bodies
This flag, currently staged in as `-experimental-skip-non-inlinable-function-bodies`, will cause the typechecker to skip typechecking bodies of functions that will not be serialized in the resulting `.swiftmodule`. This patch also includes a SIL verifier that ensures that we don’t accidentally include a body that we should have skipped.

There is still some work left to make sure the emitted .swiftmodule is exactly the same as what’s emitted without the flag, which is what’s causing the benchmark noise above. I’ll be committing follow-up patches to address those, but for now I’m going to land the implementation behind a flag.
2019-09-26 10:40:11 -07:00
Harlan Haskins
29bc645104 [TBDGen] Set installapi flag only when building in installapi (#27315)
Previously, we would unconditionally set the `installapi` flag, which
hard errors when trying to merge with a TAPI-generated TBD file that
was generated during the install phase.

Fixes rdar://42406088
2019-09-24 09:52:12 -07:00
David Ungar
a9a9069591 change compare-to-astScope-lookup to crosscheck-unqualified-lookup 2019-09-22 17:59:39 -07:00
David Ungar
c7be2def90 Merge pull request #27143 from davidungar/A-9-12-eager-off
[NFC NameLookup ASTScope] Fixes for large app, eager primary tree creation, memberCount fix.
2019-09-14 18:46:17 -07:00
David Ungar
3afd6a7146 add flag to stress scope creation 2019-09-13 22:30:49 -07:00
Harlan Haskins
c82c9b8210 [ModuleInterfaces] Remove references to 'parseable' interfaces everywhere
Now that we've settled on Module Interface as the name, let's remove the
vestiges of "Parseable Interfaces"
2019-09-13 14:55:48 -07:00
David Ungar
1415f2f7f9 LazyASTScopes only matters when ASTScopes are enabled 2019-08-28 11:31:17 -07:00
David Ungar
7992e1c6c4 Lots of cleanups, renamings, etc. 2019-08-26 16:55:18 -07:00
Doug Gregor
b4e80cfd90 [Constraint graph] Enable one-way constraints in function builders.
Enable one-way constraints by default for function builders, finishing
rdar://problem/50150793.
2019-08-19 22:49:15 -07:00
Doug Gregor
7697611c15 Merge pull request #25983 from DougGregor/one-way-constraints
[Constraint solver] Introduce one-way binding constraints.
2019-08-14 09:19:11 -07:00
David Ungar
b02b4b00ef Cleanup and fixes, also 1st cut at lazy. 2019-08-13 17:48:06 -07:00
Doug Gregor
be73a9d641 [Function builders] Add one-way constraints when applying function builders
When we transform each expression or statement in a function builder,
introduce a one-way constraint so that type information does not flow
backwards from the context into that statement or expression. This
more closely mimics the behavior of normal code, where type inference
is per-statement, flowing from top to bottom.

This also allows us to isolate different expressions and statements
within a closure that's passed into a function builder parameter,
reducing the search space and (hopefully) improving compile times for
large function builder closures.

For now, put this functionality behind the compiler flag
`-enable-function-builder-one-way-constraints` for testing purposes;
we still have both optimization and correctness work to do to turn
this on by default.
2019-08-13 12:38:46 -07:00
Harlan Haskins
7f07db5466 Merge pull request #26481 from owenv/print_diag_names
Add -debug-diagnostic-names frontend flag
2019-08-09 15:44:26 -07:00
David Ungar
09342dfa47 Add frontend flag -warn-if-astscope-lookup w/ test 2019-08-06 23:17:49 -07:00