Commit Graph

6605 Commits

Author SHA1 Message Date
Dmitri Hrybenko
94698bc469 Fix 80 cols violation
Swift SVN r16623
2014-04-21 20:47:15 +00:00
Arnold Schwaighofer
989d554a45 Add support for an assert_configuration builtin function
This patch adds support for a builtin function assert_configuration that is
replaced by constant progpagation by an appropriate value dependent on a compile
time setting. This replacement can also be disabled when serializing sil for a
library.

Using this mechanism we implement assertions that can  be disabled (or whose
behavior changes) depending on compile time build settings (Debug, Release,
DisableReplacement).

In the standard library we can now write one assert function that uses this
builtin function to provide different compile time selectable runtime behavior.

Example

Assert.swift:

@transparent
func assert<T : LogicValue>(
  condition: @auto_closure () -> T, message: StaticString = StaticString(),

  // Do not supply these parameters explicitly; they will be filled in
  // by the compiler and aren't even present when asserts are disabled
  file: StaticString = __FILE__, line: UWord = __LINE__
) {
  // Only in debug mode.
  if _isDebug() {
    assert(condition().getLogicValue(), message, file, line)
  }
}

AssertCommon.swift:

@transparent
func _isDebug() -> Bool {
  return Int32(Builtin.assert_configuration()) == 0;
}

rdar://16458612

Swift SVN r16472
2014-04-17 22:05:42 +00:00
Dmitri Hrybenko
68e8fee5fc Comment parsing: put more information into the generated XML documents
This commit adds infrastructure for conversion and testing it.

The conversion is still incomplete, pending discussion about which tags should
we use in the XML documents.  I copied the RelaxNG schema from Clang, and will
edit it accordingly.


Swift SVN r16451
2014-04-17 15:42:51 +00:00
Michael Gottesman
cffc3d372d [constant-propagation] Refactor constant propagation slightly to disable diagnostics so we can use it in the performance passes to help with branch simplification.
This commit also enables constant propagation in the performance
pipeline.

Since we are close to WWDC, this commit purposefully minimally touches
the pass (despite my hands wanted to refactor it so bad) just enough so
that we get the desired result with minimal in tree turmoil.

rdar://16604715

Swift SVN r16388
2014-04-16 01:49:16 +00:00
Michael Gottesman
1c7405343d [sil-opt] Add in support for passing in an SDK path so we can parse modules with clangimporter dependencies.
Swift SVN r16266
2014-04-12 22:35:02 +00:00
Ted Kremenek
b285190383 Don't crash when 'swift -frontend' is passed no arguments.
Fixes <rdar://problem/16584079>.

Swift SVN r16200
2014-04-11 05:23:57 +00:00
Enrico Granata
34209113fb The REPL currently tries to "warm up" by running an harmless expression, Void(), before giving the user control
This works, except when you launch it in -parse-stdlib mode, where running that expression fails, because Swift.Void wasn't pulled in, and that failure causes the REPL to quit

This patch passes down the -parse-stdlib flag to the REPL initialization code, such that it does not try to run any warm up code in -parse-stdlib mode



Swift SVN r15968
2014-04-05 00:28:55 +00:00
Jordan Rose
d52edd8675 Add -I and -F support to lldb-moduleimport-test.
Swift SVN r15751
2014-04-01 21:47:36 +00:00
Michael Gottesman
4e73547a3e Change SerializedSILLoader::create to return a unique_ptr and use that everywhere so we don't leak SILLoaders.
Swift SVN r15700
2014-03-31 22:57:03 +00:00
Michael Gottesman
0727628c8c [deserialization] Add in the linker pass.
Swift SVN r15671
2014-03-31 08:40:36 +00:00
Nadav Rotem
5500bdae22 Add a command line flag for removing cond_fails in SIL.
Swift SVN r15432
2014-03-25 00:51:01 +00:00
Michael Gottesman
5b88963e78 [SIL] Implement external SIL Witness Table declarations.
This will help with ensuring that we do not create multiple witness
table "definitions" one of which is null. That situtation yields an
IRGen assertion to be hit since the external declaration (in the guise
of a definition) has a different type from the actual deserialized
definition.

Swift SVN r14999
2014-03-13 19:52:59 +00:00
Jordan Rose
49ec7c1ea1 Use SWIFT_MODULE_CACHE_PATH for all tools.
Now that the standard library depends on Clang headers, every single tool
needs to specifically avoid using the default module cache when
SWIFT_MODULE_CACHE_PATH is set.

<rdar://problem/16294222>

Swift SVN r14937
2014-03-12 00:27:24 +00:00
Jordan Rose
a440870268 Drop the swift_driver alias for 'swift'.
Swift SVN r14936
2014-03-12 00:27:19 +00:00
Dmitri Hrybenko
e50b52fa02 Serializer/Driver: serialize comments to separate .swiftdoc files
The driver infers the filename from the module file by replacing the extension,
and passes the explicit path to the swiftdoc file to the frontend.  But there
is no option in the driver to control emission of swiftdoc (it is always
emitted, and name is always inferred from the swiftmodule name).

The swiftdoc file consists of a single table that maps USRs to {brief comment,
raw comment}.  In order to look up a comment for decl we generate the USR
first.  We hope that the performance hit will not be that bad, because most
declarations come from Clang.  The advantage of this design is that the
swiftdoc file is not locked to the swiftmodule file, and can be updated,
replaced, and even localized.


Swift SVN r14914
2014-03-11 10:42:26 +00:00
Jordan Rose
7b0d4793f6 Add the real ClangImporter as a dependency for sil-extract and sil-opt.
The standard library is about to start using some C/Objective-C
declarations internally, which means every tool needs to be import
C/Objective-C. (Don't worry, they're keeping it small.)

Apologies for your link times.

(The NullClangImporter is dead; I'll remove it next week.)

Swift SVN r14821
2014-03-08 02:37:28 +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
Chris Lattner
8869767260 Implement the rest of rdar://16242700
Fix a phase ordering problem: SILGen of a noreturn function doesn't drop an unreachable after the function,
and doing so is problematic for various reasons (all expressions would have to handle their insertion point
vaporizing, and would have to emit unreachable code diagnostics).  Instead, run a simple pass that folds
noreturn calls and diagnoses unreachable code, and do it before DI.  This prevents DI from seeing false
paths, and rejecting what seems like invalid code.



Swift SVN r14711
2014-03-06 01:29:32 +00:00
Doug Gregor
56368f87dc Put the SwiftARCPasses dylib in the right place.
Swift SVN r14600
2014-03-03 18:47:08 +00:00
Michael Gottesman
3293184b2e Don't link llvm statically into libswiftOptimizeARC.a. Actually link libswiftOptimizeARC.a into SwiftARCPasses.dylib.
This patch fixes a number of issues:

1. We were not linking libswiftOptimizeARC.a into SwiftARCPasses.dylib.
2. If you did perform that linking since libswiftOptimizeARC.a had a bunch of
llvm statically linked into it, opt would see multiple instances of certain
options causing it to error out.

Now we don't statically link in a ton of LLVM into libswiftOptimizeARC.a and
properly link libswiftOptimizeARC.a into SwiftARCPasses.dylib.

Swift SVN r14557
2014-03-01 06:31:54 +00:00
Jordan Rose
d0df0cff82 [CMake] Revert SwiftARCPasses back to add_llvm_loadable_module.
This is necessary to not link in a duplicate copy of LLVMSupport. This is
the same interface as LLVM's example modules and Clang's sample plug-ins.

Fariborz, if this breaks your Xcode setup again, please let me know and I'll
come take a look. (The Clang targets work fine for me in Xcode.)

Swift SVN r14547
2014-03-01 00:44:14 +00:00
Michael Gottesman
c25d6f8390 [mandatory-inlining] Use getOptions() instead of passing around options.
Swift SVN r14493
2014-02-28 01:51:53 +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
Michael Gottesman
3ac5018ac9 Revert "Revert r14430: Create two SILLinking steps, one before Diagnostics for transparent functions and the other after Diagnostics for non transparent functions if -sil-link-all is passed in."
This recommits r14446 with necessary changes.

The problem was that after my change SILGen was dumped before sil linking
occured. This change adds back in the code to ensure that sil linking occurs.

Swift SVN r14455
2014-02-27 07:04:51 +00:00
Dave Zarzycki
ce2635d401 Revert r14430: Create two SILLinking steps, one before Diagnostics for transparent functions and the other after Diagnostics for non transparent functions if -sil-link-all is passed in.
Swift SVN r14446
2014-02-27 03:09:55 +00:00
Michael Gottesman
0c755a55a8 Create two SILLinking steps, one before Diagnostics for transparent functions and the other after Diagnostics for non transparent functions if -sil-link-all is passed in.
Swift SVN r14430
2014-02-26 23:47:50 +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
bb0a65483c Remove swift_old.
Long live the driver!

Swift SVN r14328
2014-02-25 00:47:41 +00:00
Dmitri Hrybenko
73aa816935 Track upstream change in raw_fd_ostream API
The default (F_None) used to mean F_Text, now it is F_Binary, which is arguably
a better default.  It only matters on Windows anyway, so just use F_None (to
mean binary mode) everywhere to allow Swift to be compled with older LLVM as
well as current ToT.


Swift SVN r14312
2014-02-24 21:00:00 +00:00
Dmitri Hrybenko
fef36edc6b Try to fix the build following the LLVM raw_fd_ostream API change
Swift SVN r14304
2014-02-24 17:21:49 +00:00
Argyrios Kyrtzidis
bb4b57c053 [IDE] Introduce ide::printDeclUSR() which uses the mangler to provide a USR for a swift symbol.
Swift SVN r14279
2014-02-23 06:54:48 +00:00
Argyrios Kyrtzidis
8cb03b5cdf [CMake] Use add_swift_library() for SwiftARCPasses targets.
This makes it consistent with the rest of the swift targets and addresses rdar://16030128

Swift SVN r14277
2014-02-23 01:10:43 +00:00
Michael Gottesman
ba7dfd054a [sil-extract] Teach SILExtract how to deserialize SIL from swift modules like SILOpt.
Now sil-extract can be used on the stdlib (when we can deserialize it).

Swift SVN r14251
2014-02-22 04:11:02 +00:00
Michael Gottesman
456cd2bfb9 [sil-dis] Remove sil-dis now that its functionality is integrated into sil-opt.
Swift SVN r14239
2014-02-21 23:16:07 +00:00
Michael Gottesman
3a784587f7 [sil-opt] Teach SILOpt how to process module files.
I will be removing sil-dis in a forthcoming commit.

Swift SVN r14236
2014-02-21 23:01:13 +00:00
Michael Gottesman
8ddba95459 [sil-opt] Dump decls as well as SIL.
Swift SVN r14235
2014-02-21 23:01:13 +00:00
Michael Gottesman
2bc8e3e3ed Remove trailing whitespace. NFC.
Swift SVN r14215
2014-02-21 18:33:48 +00:00
Michael Gottesman
1300677b3f [sil-opt] Remove cruft code that was supposed to call the verifier after every
pass and instead was calling the verifier after adding every pass to the pass
manager (i.e. just wasting cpu time). Instead enable sil-verify-all by default
to get the same effect.

Swift SVN r14213
2014-02-21 18:29:32 +00:00
Michael Gottesman
e35f93a551 [sil-opt] Declare PassKind in an anonymous namespace instead of the global scope.
Swift SVN r14212
2014-02-21 18:29:32 +00:00
Michael Gottesman
903d4e85a3 [sil-opt] Change banner description to something actually descriptive.
Swift SVN r14211
2014-02-21 18:21:37 +00:00
Michael Gottesman
682530209b Fix typo = /. NFC.
Swift SVN r14193
2014-02-21 00:49:21 +00:00
Michael Gottesman
9c3b1fe38e Somehow this header got messed up = /. Fix it quick.
Swift SVN r14192
2014-02-21 00:46:12 +00:00
Michael Gottesman
0f45dbb8e7 A few small cleanups from onlist review by Jordan and my own review of the code.
The most interesting one is that the sil-dis test is modified to not run IRGen
which should lower the amount of time to run the test.

Swift SVN r14190
2014-02-21 00:44:05 +00:00
Michael Gottesman
c775782755 [sil-dis] Initial commit of sil deserialization utility "sil-dis".
Currently supports dumping decls and SILModules from the standard library only.
This restriction is good enough for my purposes of verification of the
deserialization of SIL and allows me to ignore the complexity of having multiple
source files (which not being the stdlib implies most of the time).

Swift SVN r14187
2014-02-21 00:24:35 +00:00
Nadav Rotem
d52cbc89dd Rename AllocRefElim -> DeadObjectElim. NFC.
Swift SVN r14179
2014-02-20 23:14:59 +00:00
Jordan Rose
eeda180d81 [PrintAsObjC] Emit the ObjC header after SILGen...
...because doing so might cause more Clang types to be deserialized, which
before led to trying to SILGen un-type-checked auto-generated helpers.

Swift SVN r14017
2014-02-18 00:23:12 +00:00
Jordan Rose
69d849772b Always honor -dump-parse, -dump-ast, or -print-ast even if there were errors.
...though -print-ast seems a bit broken right now.

<rdar://problem/16084143>

Swift SVN r14000
2014-02-17 18:48:09 +00:00
Jordan Rose
0f54c34053 Use -resource-dir for iOS builds and tests instead of -I.
As part of this, have the standard library target be responsible for
symlinking Clang's headers into the resource directory, instead of the
compiler target. This makes sure the headers show up in all copies of
the build directory.

This brings our iOS testing closer to what Xcode will do, which will
hopefully avoid issues like <rdar://problem/16052579>.

Swift SVN r13890
2014-02-14 01:27:16 +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