Commit Graph

2021 Commits

Author SHA1 Message Date
Jordan Rose
6e96e26a81 Add CompilerInvocation::loadFromSerializedAST.
This is mainly for the debugger's use, to set up CompilerInvocations that
match how a particular app was compiled in certain important ways. Today
that's the target (which is also in the binary), the SDK path (which in
the long run should probably be an SDK name), and any random -Xcc options
we need to pass (which we should probably attempt to minimize).

Because there's only one target and SDK per context, and because -Xcc
options can easily conflict, this is only intended to be used once per
CompilerInvocation.

Note that search paths are not covered by this; they are already being
added at the time the module is loaded. See r24545.

Completes rdar://problem/17670778.

Swift SVN r25227
2015-02-12 05:32:37 +00:00
Justin Bogner
a49008298e InstrProf: Set up the basic infrastructure for profiling swift
This adds the -profile-generate flag, which enables LLVM's
instrumentation based profiling. It implements the instrumentation
for basic control flow, such as if statements, loops, and closures.

Swift SVN r25155
2015-02-11 01:06:18 +00:00
Joe Groff
a4c777320e IRGen: Change type layout verifier to take a type by name to verify.
Swift SVN r25088
2015-02-09 02:51:41 +00:00
Joe Groff
8e1e6665a7 IRGen: Start a type verifier to fuzz static type info against runtime type info.
We've had a rash of bugs due to inconsistencies between how IRGen and the runtime think types are laid out. Add a '-verify-type-layout' mode to the frontend that causes IRGen to emit a bunch of code that compares its static assumptions against what the runtime value witness does.

Swift SVN r24918
2015-02-03 16:47:25 +00:00
Jordan Rose
c97c949fcf Add frontend flag -import-module <name>.
This implicitly adds the named module as an import of every source file
in the module being compiled. This is not intended to be used generally,
but will be useful for playgrounds.

rdar://problem/19605934

Swift SVN r24905
2015-02-02 22:20:13 +00:00
Joe Groff
9489605a8f Enable vtable thunks.
Swift SVN r24736
2015-01-26 21:52:20 +00:00
Joe Groff
a449948275 SILGen: Emit vtable thunks to handle optional variance.
If a subclass overrides methods with variance in the optionality of non-class-type members, emit a thunk to handle wrapping more optional parameters or results and force-unwrapping any IUO parameters made non-optional in the derived. For this to be useful, we need IRGen to finally pay attention to SILVTables, but this is a step on the way to fixing rdar://problem/19321484.

Swift SVN r24705
2015-01-24 05:21:26 +00:00
Graham Batty
83dd7bf854 frontend: set a sensible default objc-interop.
Swift SVN r24642
2015-01-22 18:20:23 +00:00
Jordan Rose
8ee17a4d0d Serialize search paths when building an app, for a better debugging experience.
There's also a testing option, -serialize-debugging-options, to force this
extra info to be serialized even for library targets. In the long run we'll
probably write out this information for all targets, but strip it out of
the "public module" when a framework is built. (That way it ends up in the
debug info's copy of the module.)

Incidentally, this commit includes the ability to add search paths to the
Clang importer on the fly, which is most of rdar://problem/16347147.
Unfortunately there's no centralized way to add search paths to both Clang
/and/ Swift at the moment.

Part of rdar://problem/17670778

Swift SVN r24545
2015-01-20 03:02:54 +00:00
Jordan Rose
a3a6c2695b Put the current target into LangOptions.
This has been long in coming. We always had it in IRGenOpts (in string form).
We had the version number in LangOpts for availability purposes. We had to
pass IRGenOpts to the ClangImporter to actually create the right target.
Some of our semantic checks tested the current OS by looking at the "os"
target configuration! And we're about to need to serialize the target for
debugging purposes.

Swift SVN r24468
2015-01-16 02:48:54 +00:00
Mark Lacey
cc5b6c7284 Add a hidden option to disable the LLVM SLP vectorizer.
Swift SVN r24341
2015-01-10 00:51:08 +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
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
Jordan Rose
8612e24e0f -debug-time-function-bodies: dump time spent type-checking each function.
This is a hidden frontend-only option intended for debugging purposes,
mainly for identifying where in a file the type checker is spending most
of its time. Use with "sort -g" to get the top problem functions.

Swift SVN r23789
2014-12-08 23:07:07 +00:00
Michael Gottesman
6fdf2a2a2f [silgen] Add support for emitting guaranteed self behind the flag -enable-guaranteed-self.
This does not have any tests since I am going to start going through SILGen
tests and updating them for guaranteed self as the appropriate tests.

*NOTE* There is more work to be done in terms of thunks, but the basic
functionality is done.

rdar://15729033

Swift SVN r23653
2014-12-03 21:20:25 +00:00
Adrian Prantl
30976b2eb3 No need to emit a Swift module in -gline-tables-only mode.
Thanks Jordan for pointing this out!

Swift SVN r23616
2014-12-02 18:07:37 +00:00
Adrian Prantl
41a30f5988 Support line table only DWARF for Swift. <rdar://problem/19106981>
The new option is called -gline-tables-only to mirror clang.

Swift SVN r23615
2014-12-02 17:44:23 +00:00
Mark Lacey
d2b90ad266 Add an option to disable running the LLVM verifier.
Add a new frontend option, -disable-llvm-verify, to disable adding the
LLVM verifier pass to the pipeline.

Swift SVN r23565
2014-11-23 08:05:51 +00:00
Graham Batty
c835beb0b8 Remove IRGenOptions objc-interop flag.
Swift SVN r23166
2014-11-07 22:39:13 +00:00
Graham Batty
63a429f16e Changes to code generation to support non-objc targets
Swift SVN r23118
2014-11-05 18:05:55 +00:00
Michael Gottesman
f33e6306e8 [func-sig-opts] Enable func sig opts.
This currently handles owned -> guaranteed argument conversion and dead argument
elimination.

RecursiveOwnedParameter||90.0%
ClassArrayGetter|||||||||23.3%
Life|||||||||||||||||||||16.7%
Prims||||||||||||||||||||11.2%
StringWalk|||||||||||||||5.7%

The next step is to implement SROA and address -> value optimizations.

rdar://16917049

Swift SVN r23023
2014-10-30 23:22:51 +00:00
Jordan Rose
fc09bd4585 Add basic reference tracking based on name lookups.
This tracks top-level qualified and unqualified lookups in the primary
source file, meaning we see all top-level names used in the file. This
is part of the intra-module dependency tracking work that can enable
incremental rebuilds.

This doesn't quite cover all of a file's dependencies. In particular, it
misses cases involving extensions  defined in terms of typealiases, and
it doesn't yet track operator lookups. The whole scheme is also very
dependent on being used to track file-level dependencies; if C is a subclass
of B and B is a subclass of A, C doesn't appear to depend on A. It only
works because changing A will mark B as dirty.

Part of rdar://problem/15353101

Swift SVN r22925
2014-10-24 22:23:03 +00:00
Argyrios Kyrtzidis
ec4e5c0543 [Frontend] Add option and test for the "-playground without the transform" mode.
Swift SVN r22916
2014-10-24 17:41:17 +00:00
Argyrios Kyrtzidis
0e55e054b9 [Frontend] Allow explicit control for enabling the playground instrumenter.
Related to rdar://18095436

Swift SVN r22915
2014-10-24 17:16:59 +00:00
Jordan Rose
fe68e7512f Add a -gnone option that can negate a previous -g option.
The name -gnone was chosen by analogy with -O and -Onone. Like -O/-Onone,
the last option on the command line wins.

The immediate use case for this is because we want to be able to run the
tests with -g injected into every command line, but some tests will fail
when debug info is included. Those particular tests can be explicitly marked
-gnone.

rdar://problem/18636307

Swift SVN r22777
2014-10-15 22:12:07 +00:00
Doug Gregor
91ddaf59eb Archetype builder: start tracking the locations and reasons for specific requirements.
Whenever we add a requirement, we now know

  (1) Why we added the requirement, e.g., whether it was explicitly written, inferred from a signature, or introduced by an outer scope.
  (2) Where in the source code that requirement originated.

Also add a debugging flag for dumping the archetype builder information, so we can write tests against it.

This is effectively NFC, but it's infrastructure to help a number of requirements-related tasks.

Swift SVN r22638
2014-10-09 21:52:28 +00:00
Graham Batty
7676c8240d Add compile time config flag for detecting objc-interop.
Swift SVN r22605
2014-10-08 17:09:34 +00:00
Jordan Rose
49a6c8eb7b Do all target info management in Clang, and drop -target-abi / -target-feature.
Previously we hardcoded a few important default CPUs, ABIs, and features into
Swift's driver, duplicating work in Clang. Now that we're using Clang's
driver to create the Clang "sub-compiler", we can delegate this work to Clang.

As part of this, I've dropped the options for -target-abi (which was a
frontend-only option anyway) and -target-feature (which was a hidden driver
option and is a frontend-only option in /Clang/). We can revisit this later
if it becomes interesting. I left in -target-cpu, which is now mapped
directly to Clang's -mcpu=.

Swift SVN r22449
2014-10-01 23:55:40 +00:00
Graham Batty
a1e0b0fbf7 Driver: More stubbing for Linux support
Swift SVN r22362
2014-09-29 21:14:32 +00:00
Devin Coughlin
b727b6d932 Treat potentially unavailable global variable references as optional.
This patch adds the ability (-enable-experimental-unavailable-as-optional) to
treat potentially unavailable declarations as if they had optional types. For
the moment, this is only implemented for global variables.

The high-level approach is to (1) record the potential unavailability of a
declaration reference in the overload choice during constraint generation; (2)
treat the declaration as if it had an optional type during overload resolution
(this is similar to how optional protocol members are treated); and (3) add an
implicit conversion (UnavailableToOptionalExpr) during constraint application
to represent the run-time availability check and optional injection.

This patch does not implement SILGen for UnavailableToOptionalExpr.


Swift SVN r22245
2014-09-24 00:07:46 +00:00
Argyrios Kyrtzidis
374bf23f2b [TypeChecker] Introduce frontend option '-debug-forbid-typecheck-prefix' to protect against unnecessary typechecking,
for testing purposes.

When enabled, if the typechecker tries to typecheck a decl or unresolved identifier with the provided
prefix, then an llvm fatal_error will get triggered.

This approach has the advantage that it is very easy to write tests for unnecessary typechecking for a wide range of functionality,
for the compiler or SourceKit, for code-completion, indexing, etc.

Swift SVN r22003
2014-09-17 04:17:49 +00:00
Devin Coughlin
d33876ec5c Add option to enable experimental API availability checking
Swift SVN r21884
2014-09-11 18:46:56 +00:00
Michael Gottesman
93494cf44f [func-sig-opts] Add frontend option -enable-func-sig-opts to enable function signature optimization as a late pass. This is disabled by default and is only for testing purposes.
Swift SVN r21787
2014-09-08 21:29:09 +00:00
Doug Gregor
b6248c8342 Remove the -enable-objc-failable-initializers option.
As part of this, failable initializers get enabled by default for
swift-ide-test.


Swift SVN r21704
2014-09-04 15:31:02 +00:00
Joe Groff
19b470b454 Remove '-emit-NSApplicationMain' staging option.
Swift SVN r21698
2014-09-04 05:52:31 +00:00
Jordan Rose
adc25c8b9f Staging: Guard private discriminators under -enable-primary-discriminators.
...rather than let this series of out-of-tree commits get any bigger.

Swift SVN r21601
2014-08-30 00:17:23 +00:00
Argyrios Kyrtzidis
0de5a66345 [Frontend] Introduce FrontendOptions::NoneAction, when the client wants custom control on how to handle an invocation.
This fixes SourceKit tests after r21537.

Swift SVN r21564
2014-08-29 04:58:37 +00:00
Joe Groff
8f52302f8e SILGen: Implement artificial main for NSApplicationMain.
We're not sure how to trigger this from source code yet, so trigger it with a hidden -emit-NSApplicationMain frontend flag for now.

Swift SVN r21563
2014-08-29 04:45:47 +00:00
Sean Callanan
2c50b0ca48 swift -frontend "" shouldn't enter the REPL by default.
This patch fixes a problem where a CompilerInvocation
with no arguments would set the LangaugeOpts etc. up for
the deprecated-integrated-repl, including setting the
module name etc.  Now this only happens if you explicitly
invoke swift -frontend -repl.

Updated testcases that care, and added a new testcase to
ensure that an error is properly generated.

<rdar://problem/17918172>


Swift SVN r21537
2014-08-28 18:38:13 +00:00
Jordan Rose
9b0d643029 Move 'Playground' into LangOptions and out of FrontendOptions and IRGenOptions.
Also, use 'Playground' to control the behavior of ignored expressions
(which are not an error because they are displayed in the playground log).

This is preparation for LLDB no longer passing 'DebuggerSupport' for a
playground <rdar://problem/18090611>. 'DebuggerSupport' now only applies
to REPL-like contexts and enables identifiers beginning with $, special
rules for parsing top-level code, ignored expressions (like playgrounds),
and the @LLDBDebuggerSupport attribute.

Besides ignored expressions, 'Playground' enables the playground transformation
and provides an entry point for debugger initialization.

Note that this is a bit insincere---many of the options controlled by both
'Playground' and 'DebuggerSupport' really only apply to the main source file
or main module. If/when we add back support for source file imports, we'll
need to revisit all of LangOptions and see which of them should /really/
apply to /everything/ in the ASTContext.

Swift SVN r21384
2014-08-21 22:36:24 +00:00
Doug Gregor
1a8f5e1eec Remove -enable-optional-lvalues and its language option; they're always on anyway.
Swift SVN r21356
2014-08-21 15:53:31 +00:00
Doug Gregor
7cae0cfc8e Remove -enable-dynamic and its language option; it's always on anyway.
Swift SVN r21354
2014-08-21 15:15:12 +00:00
Doug Gregor
5709a86f2f Start importing Objective-C initializers and factory methods using failable initializers.
In this mode, use nullability information on the result type of the
initializer or factory method to determine failability of the
initializer. This is behind the flag
-enable-objc-failable-initializers until we have the SILGen support in
place.



Swift SVN r21341
2014-08-21 04:50:20 +00:00
Argyrios Kyrtzidis
c454acefdf [Frontend] Rename EnableObjCAttrRequiresObjCModule -> EnableObjCAttrRequiresFoundation and enable it by default.
This is enabled by default because SILGen can crash when @objc is used without importing Foundation, but
it gets disabled when compiling the Swift stdlib.

Addresses rdar://17931250.
Related test case on the SourceKit side.

Swift SVN r21319
2014-08-20 21:19:56 +00:00
Ted Kremenek
acd30c9d4b Rename '-enable-objc-attr-requires-objc-module' to '-enable-objc-attr-requires-foundation-module' to accurately reflect its behavior.
Swift SVN r21304
2014-08-20 06:34:48 +00:00
Mark Lacey
e76a6c7333 Add -sil-print-pass-name option.
Prints the pass number and name along with the function being
processed. This can be handy when bisecting by pass number.

Swift SVN r21219
2014-08-14 22:38:30 +00:00
Joe Pamer
71cf758055 Mitigate exponential solver behavior (rdar://problem/17162690)
While we work out the remaining performance improvements in the type checker, we can improve the user experience for some "runaway solver" bugs by setting a limit on the amount of temporary memory allocated for type variables when solving over a single expression.

Exponential behavior usually manifests itself while recursively attempting bindings over opened type variables in an expression. Each one of these bindings may result in one or more fresh type variables being created. On average, memory consumption by type variables is fairly light, but in some exponential cases it can quickly grow to many hundreds of megabytes or even gigabytes. (This memory is managed by a distinct arena in the AST context, so it's easy to track.) This problem is the source of many of the "freezing" compiler and SourceKit bugs we've been seeing.

These changes set a limit on the amount of memory that can be allocated for type variables while solving for a single expression. If the memory threshold is exceeded, we can surface a type error and suggest that the user decompose the expression into distinct, less-complex sub-expressions.

I've set the current threshold to 15MB which, experimentally, avoids false positives but doesn't let things carry on so long that the user feels compelled to kill the process before they can see an error message. (As a point of comparison, the largest allocation of type variable data while solving for a single expression in the standard library is 592,472 bytes.) I've also added a new hidden front-end flag, "solver-memory-threshold", that will allow users to set their own limit, in bytes.

Swift SVN r20986
2014-08-03 23:10:42 +00:00
Doug Gregor
f52c6789db Track the minimum deployment target and use it for 'unavailable' computations.
Swift SVN r20955
2014-08-02 18:05:45 +00:00
Ben Langmuir
d197964680 Rename -integrated-repl to -deprecated-integrated-repl
Swift SVN r20781
2014-07-30 22:09:37 +00:00
Jordan Rose
0481b87ba5 Move target configuration setup into CompilerInvocation.
Without this, clients that don't use a CompilerInstance (like LLDB) won't
have target configuration options available.

Also, move minimum OS checking into the driver. This makes sure the check
happens early (and only once), and in general fits the philosophy of
allowing the frontend to use configurations that might be banned for users.

<rdar://problem/17688913>

Swift SVN r20701
2014-07-29 21:48:59 +00:00