Commit Graph

4571 Commits

Author SHA1 Message Date
Sean Callanan
3b95376949 Added a new AST transformation pass called the
"Playground Transform."  This is an
instrumentation pass that adds calls to a
function called playground_log at locations of
interest.  Roughly speaking, these locations are

- Initialization of variables
- Modification of variables
- Expressions returning values
- Application of mutating methods on objects

The playground transform currently only finds
modifications of variables, but the intent is to
make all of these cases work.

It is enabled by a frontend option, and can
also be invoked by calling

swift::performPlaygroundTransform(SF)

which is the way LLDB, its main client, will
use it.

The frontend option is intended for testing,
and indeed I will add tests for this
transformation in the coming week as I bring
more functionality online.


Swift SVN r14801
2014-03-07 22:59:19 +00:00
Dmitri Hrybenko
b30edaeed6 Remove 'swift::' qualifications that are not needed
Swift SVN r14780
2014-03-07 13:05:28 +00:00
Dmitri Hrybenko
ba33352636 Move comment to the correct place
Swift SVN r14779
2014-03-07 12:32:42 +00:00
Dmitri Hrybenko
b62e7e5271 Simplify code, NFC
Swift SVN r14778
2014-03-07 12:24:36 +00:00
Dmitri Hrybenko
ef0942c69c Add a convenience API SourceManager::addMemBufferCopy() to simplify adding a
buffer in case the client does not need a pointer to the buffer.


Swift SVN r14777
2014-03-07 11:41:08 +00:00
Dmitri Hrybenko
255b8e88c8 Fix a leak that I introduced in r14729: FrontendOptions does not own input
buffers, so undo 'unique_ptr'fication here


Swift SVN r14733
2014-03-06 13:53:04 +00:00
Dmitri Hrybenko
f232267f23 Replace llvm::OwningPtr with std::unique_ptr
It looks like llvm::OwningPtr is going to be removed soon.


Swift SVN r14729
2014-03-06 09:47:17 +00:00
Dmitri Hrybenko
cd48638f9a Fix a use-after-free caused by creating DerivedFileUnit on the fly
Sema was creating DerivedFileUnit on the fly, while something else is iterating
over FileUnits in the module.  The fix is to create DerivedFileUnit in advance.
This change immediately uncovered a lot of code that assumed that the module
consists of a single FileUnit at certain conditions.  This patch also fixes
that code (SourceKit patch is separate, not sending it).

The test change is because now operator == on NSObjects is correctly recognised
as coming from a system module.

rdar://16153700, rdar://16227621, possibly rdar://16049613


Swift SVN r14692
2014-03-05 22:24:25 +00:00
Dmitri Hrybenko
3430229a79 Simplify code
Swift SVN r14641
2014-03-04 11:41:47 +00:00
Dmitri Hrybenko
15fd90c31c Revert r14589, a proper fix will be committed soon
Swift SVN r14639
2014-03-04 10:19:22 +00:00
Jordan Rose
6685f72f3b Use Clang's stable enum values for serialized diagnostics.
A refinement of r14545, which was a response to "remarks" being added to Clang.
This commit requires Clang commit r202733.

Swift SVN r14613
2014-03-03 22:16:06 +00:00
Dmitri Hrybenko
a5c5daf336 Fix a use-after-free: type checker can add 'DerivedFileUnit's now, so we need
to be careful when iterating over the vector of all files and type checknig
them.

This is related to rdar://16153700, but it looks like that it does not yet
completely fix it.


Swift SVN r14589
2014-03-03 11:21:33 +00:00
Jordan Rose
3826099df4 Keep serialized diagnostic levels in sync with Clang.
Who would have thought this would ever change? But over in open-source-land,
they're adding "remarks" to the diagnostics (kind of like standalone notes)
and that shifted over the IDs of serialized diagnostics.

Swift SVN r14545
2014-03-01 00:44:13 +00:00
Michael Gottesman
29e1a53bbb [deserialization] Deserialize transparent functions lazily iff they will be used in mandatory inlining.
Swift SVN r14490
2014-02-28 01:05:01 +00:00
Ted Kremenek
028f9d0561 Remove rest of Makefile build except for 'docs' and 'www'.
For 'docs' and 'www' it is possible these are still being used,
as they work independent of the Makefile build.  Keeping them for now.

Swift SVN r14418
2014-02-26 22:21:25 +00:00
Jordan Rose
cadd6edb9d Move EnableObjCOptional to LangOptions (from ClangImporterOptions).
This is a staging option, and I'm about to use it for type-checker changes.

No functionality change.

Swift SVN r14415
2014-02-26 22:15:53 +00:00
Joe Pamer
0be3362ba9 Update target configuration values to conform with current conventions (use i386, x86_64, arm and arm64 instead of I386, X64, ARM and ARM64).
Swift SVN r14371
2014-02-26 02:06:30 +00:00
Jordan Rose
0f71586952 [ClangImporter] Start importing Objective-C references using UncheckedOptional.
This is hidden behind the frontend flag -enable-objc-optional. Use -Xfrontend
when invoking the Swift driver.

Part of <rdar://problem/15189135>

Swift SVN r14332
2014-02-25 02:04:02 +00:00
Dmitri Hrybenko
db6f0772b4 Allow Swift to be compiled with open-source LLVM
Swift SVN r14311
2014-02-24 20:57:36 +00:00
Joe Pamer
b46d20240d Update build configuration tests to be independent of their runtime platform.
Also, add more tests for the "os" and "arch" target configurations, to exercise likely
build configurations for iOS and the iOS simulator.

Swift SVN r14307
2014-02-24 18:16:50 +00:00
Joe Pamer
988a5877f2 Some updates:
- Respond to Doug's code review feedback
   - Stop hacking around with scopes and use "emplace" to work around RAII in the inactive config case
   - Limit use of StringRef on the front-end, in favor of std::string
   - Use ArrayRef rather than SmallVector within IfConfigDecl
   - Reorder new property declarations on BraceStmt to prevent unnecessary alignment issues
- Update ParseBraceItems to better capture top-level declarations, rather than using token lookahead

Swift SVN r14306
2014-02-24 18:16:49 +00:00
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00
Joe Groff
c0a0a8b584 Add a -sil-opt-pass-count frontend flag.
Until our SIL printing and parsing is robust enough to round-trip, this is useful for bisecting optimizer issues.

Swift SVN r14061
2014-02-18 23:37:25 +00:00
Michael Gottesman
190de1cc6a Add support for option -time-transforms which causes the pass manager to emit time information for each transform run.
Swift SVN r14042
2014-02-18 15:50:17 +00:00
Jordan Rose
93b87edcbe Add -resource-dir option to find lib/swift directory.
This is equivalent to Clang's -fresource-dir; it provides the location of
compiler modules and libraries.

No end-user-visible changes, but the iOS build will no longer have to use
-I to build and test its own standard libraries.

Swift SVN r13888
2014-02-14 01:27:15 +00:00
Jordan Rose
327439f3ab New frontend: use the target triple to find runtime modules and libraries.
We were accepting -target, but not bothering to recompute the runtime
include path, so we always got lib/swift/macosx (the default target's
platform directory). Fix this by always updating the path after all
options have been parsed.

Tests to come in subsequent commits.

<rdar://problem/16052579>

Swift SVN r13887
2014-02-14 01:27:15 +00:00
Jordan Rose
513e6b5b33 Don't use a default argument in a lambda.
This is a Clang extension to C++11, and it's easy enough to not do it.

No functionality change.

Swift SVN r13803
2014-02-12 01:43:55 +00:00
Jordan Rose
798e13d15c Wire up -emit-objc-header[-path] options that don't do anything yet.
These options piggyback on the "merge module" phase of the driver
because the header we output needs an entire complete module.

Swift SVN r13800
2014-02-12 01:19:13 +00:00
Michael Gottesman
648d3fee40 Pass in Args.size() - 1, not Args.size() so the nullptr arg is not included in "argc".
Swift SVN r13762
2014-02-10 22:58:51 +00:00
Michael Gottesman
f88bc1ed3e Teach the frontend how to pass through -Xllvm commands.
This patch allows you to pass through commands to llvm from the driver so now
one can when compiling swift files get debug messages!

Swift SVN r13761
2014-02-10 22:49:56 +00:00
Jordan Rose
c24a6a7b46 [driver] Disallow "swift" as a module name unless -parse-stdlib is passed.
I didn't bother duplicating this check in -frontend mode. I think that's
acceptable.

<rdar://problem/15083796>

Swift SVN r13759
2014-02-10 22:40:44 +00:00
Jordan Rose
0de8d19514 Define globals for the names of the stdlib, ObjectiveC, and Foundation modules.
This is mostly useful for the standard library, whose name is going to
change to "Swift" soon. (See <rdar://problem/15972383>.) But it's good DRY.

Swift SVN r13758
2014-02-10 22:40:42 +00:00
John McCall
b095a5efd8 Add -debugger-support to permit the inevitable series of exceptions
and special-cases that we want to permit when parsing for the debugger.

Swift SVN r13754
2014-02-10 18:47:00 +00:00
Jordan Rose
cbcf17f9bd Stop leaking memory from Module and FileUnit.
Also, disallow creating Modules and FileUnits on the stack. They must always
live as long as the ASTContext.

<rdar://problem/15596964>

Swift SVN r13671
2014-02-08 02:12:57 +00:00
Jordan Rose
cb83bb02a8 Provide the correct primary file name to IRGenOpts.
Previously, we were always using the first file name as the main source
file name in the debug info, which was completely wrong and led to only
that file having debug info.

<rdar://problem/15786017>, again.

Swift SVN r13665
2014-02-08 00:13:45 +00:00
Andrew Trick
731000b4cd Added -sil-print-all and -sil-verify-all options.
Swift SVN r13662
2014-02-07 23:07:11 +00:00
Connor Wakamo
9df53c5c71 [frontend] Switch -debug-assert-* from llvm_unreachable() to assert(0).
Swift SVN r13656
2014-02-07 22:30:40 +00:00
Connor Wakamo
9747d87ff6 [frontend] Added a handful of options to force the frontend to assert or crash.
Added -debug-assert-immediately and -debug-crash-immediately, which cause an
llvm_unreachable or LLVM_BUILTIN_TRAP to execute during argument parsing.

Added -debug-assert-after-parse and -debug-crash-after-parse, which cause an
llvm_unreachable or LLVM_BUILTIN_TRAP to execute after calling
CompilerInstance::performParse().

This fixes <rdar://problem/16013025>.

Swift SVN r13653
2014-02-07 22:03:32 +00:00
Andrew Trick
04b2b5256b First implementation of <rdar://15922760> Deep devirtualization -
specialize on polymorphic arguments.

This can be enabled with: -sil-devirt-threshold 500.

It currently improves RC4 (when enabled) by 20%, but will be much more
important after Michael's load elimination with alias analysis lands.

This implementation is suitable for experimentation. Superficial code
reviews are also welcome. Although be warned that the design is overly
complex and I plan to rewrite it. I initially abandoned the idea of
incrementally specializing one function at a time, thinking that we
need to analyze full chains. However, I since realized after talking
to Nadav that the incremental approach can be made to work. A lot of
book-keeping will go away with that change.

TODO:

- Resolve protocol argument types. Currently we assume they can be
  reinitialized at applies, but I don't think they can unless they are
  @inouts.  This is an issue with the existing local devirtualizer
  that prevents it working across calls.

- Properly mangle the specialized methods. Find existing
  specializations by demangling rather than maintaining a map.

- Rewrite the logic for specializing chains for simplicity.

- Enable by default.

Swift SVN r13642
2014-02-07 19:10:27 +00:00
Jordan Rose
302f9cb50d Disallow importing other Swift source files as modules.
Because this is useful in testing, I've left in a frontend option
-enable-source-import for both swift and swift-ide-test that sidesteps the
module restriction. Right now, though, this is the right thing to avoid
users running into strange issues when they import another file within
their module and Swift treats it as a separate module.

<rdar://problem/15937521>

Swift SVN r13248
2014-01-31 23:01:04 +00:00
Jordan Rose
0820d82e20 Rename '-enable-arc-opts=false' to '-disable-arc-opts'.
Part of the migration to the new driver. With this commit, the only
failures in the test suite using the new frontend are features we don't
intend to port over. Hooray!

Swift SVN r13198
2014-01-31 02:34:37 +00:00
Jordan Rose
6af4dbf0e9 Move SILLinkMode to SILOptions.
SILSerializeAll and EmitVerboseSIL are /not/ being moved because they are
options controlling the output, not about SILGen and SIL passes.

No functionality change.

Swift SVN r13197
2014-01-31 02:34:34 +00:00
Jordan Rose
c7f1064527 Extract '-sil-inline-threshold' from the performance inliner.
Plumbing this through to the inliner necessitated the creation of a
SILOptions class (like FrontendOptions and IRGenOptions). I'll move
more things into this soon.

One change: for compatibility with the new driver, the option must be
specified as "-sil-inline-threshold 50" instead of "-sil-inline-threshold=50".
(We're really trying to be consistent about joined-equals vs. separate
in the new frontend.)

Swift SVN r13193
2014-01-31 01:52:12 +00:00
Jordan Rose
bac31d985a Add '-sil-serialize-all' testing option to the new frontend.
Swift SVN r13190
2014-01-31 01:02:06 +00:00
Jordan Rose
e37d2393d1 Modules containing SIL may not be emitted before SIL diagnostics.
...and probably should not be emitted before optimization passes.
The new frontend got this wrong, and the old one pretended to allow it but
then silently didn't write a module at all.

Swift SVN r13189
2014-01-31 01:02:06 +00:00
Connor Wakamo
ba76567dea [frontend] In ParseIRGenArgs(), set IRGenOptions::ModuleName using the value in FrontendOptions.
Swift SVN r13186
2014-01-31 00:12:07 +00:00
Jordan Rose
f165afe1aa Replace "-enable-sil-linking=false" with "-disable-sil-linking".
Also, restructure so that the option isn't declared in a random library file.
(And do the same with "-sil-link-all".)

Part of the migration to the new driver.

Swift SVN r13184
2014-01-31 00:02:46 +00:00
Connor Wakamo
0d483cdd88 [driver] Emit real diagnostics in the driver and integrated frontend instead of just printing to stderr.
Added DiagnosticsDriver.def and DiagnosticsDriver.h for driver-only diagnostics.
(Diagnostics which are shared with the frontend remain in
DiagnosticsFrontend.{def,h}.)

Added a DiagnosticEngine& to Compilation, so that it can emit diagnostics for
events which occur while performing Jobs.

Replaced all of the locations where we were manually printing error messages to
emitting real diagnostics, adding diagnostics if necessary.

Updated Driver::buildCompilation() so that it fails early if any errors were
encountered.

Updated test/Driver/actions.swift to pass a -module-name for multi-input tests.

Swift SVN r13175
2014-01-30 22:42:16 +00:00
Connor Wakamo
c38c95c0a1 Fixed indentation issue.
Swift SVN r13159
2014-01-30 18:44:40 +00:00
Connor Wakamo
68290c72e3 [frontend] If there is a primary input, only call performTypeChecking() on the primary input.
This has the potential to significantly reduce compile times in primary file
mode: for example, compiling Song.swift from the Name That Tune example as the
primary file previously took ~2.0s with a release build on my machine; with this
change, it now only takes ~0.8s. (The old compile time was presumably dominated
the time it takes to type-check AppDelegate.swift, which is a larger file.)

Swift SVN r13140
2014-01-30 04:53:19 +00:00