Commit Graph

28603 Commits

Author SHA1 Message Date
Dmitri Gribenko
7333c1995f Enable lightweight assertions in Linux packages 2015-11-30 21:07:13 -07:00
Dmitri Gribenko
4f8773f40e Add a test feature 'swift_ast_verifier' 2015-11-30 21:07:13 -07:00
Erik Eckstein
e15132a6f7 Revert "Compile StdlibUnittest with -sil-serialize-all."
This reverts commit adc92bab45.

It caused a fail of stdlib/AtomicInt.swift on linux.
2015-11-30 16:53:08 -07:00
Slava Pestov
3db62444d9 IRGen: Make more enum tests work on Linux 2015-11-30 15:24:34 -08:00
Joe Groff
bac64f3a11 More macro namespace qualification hygiene
NFC
2015-11-30 15:16:43 -08:00
David Farler
6f806b418f Compare top-level modules when deciding visibility for redeclarations
When importing C declarations, one can come across a redeclaration due
to two different clang modules textually including the same header.

Previously, to decide visibility of a declaration from a particular
module, the module in which it is redeclarated had to exactly match the
one we saw before, so a struct defined in A.B.C might cause it to be
hidden in A.X.Y, because we were already popping off submodule names on
the "left hand side", so the module comparison was A != A.X.Y. If
someone imports A.X.Y and expects that struct, they won't see it.

Now, strip off submodules of the "right hand side", correctly comparing
if the top-level modules match (A == A).

This may have the effect of allowing more declarations to be visible
than before but it prevents weird situations where struct typedefs can
be hidden in overly complicated nested header includes normally found in
OS system headers.

rdar://problem/23588593
2015-11-30 15:03:41 -08:00
Mishal Shah
1cc28c769e Default toolchain install location changed to /Library 2015-11-30 14:50:52 -08:00
Slava Pestov
2194aa59c4 ABI.rst: Document enum reflection metadata 2015-11-30 13:32:55 -08:00
Slava Pestov
ca7254c53d IRGen: Preliminary support for resilient enums
Resilient enums are manipulated as opaque values.

Clients are still allowed to assume physical case indices and case
payload types for now -- we might add a level of indirection here,
which would require designing a new case dispatch mechanism.

Resilient enums are never constructed directly, only by calling
case constructor functions. Case constructors already get emitted,
however they're [transparent] -- this will change in a subsequent
patch.

We could save on code size by emitting an InjectEnumTag value
witness function that can construct any case given a physical case
number, rather than emitting constructors for each case, but for
now going through case constructor functions will suffice.
2015-11-30 13:32:55 -08:00
Slava Pestov
c06f3353c9 IRGen: Remove unused IGM parameter from some methods on EnumImplStrategy, NFC
We already stash the IRGenModule in an instance variable.
2015-11-30 13:32:55 -08:00
Slava Pestov
9ee10e7d39 IRGen: destructiveProjectEnumData() value witness doesn't need a return value
The rest of the runtime assumes the payload starts at the beginning
of the enum, so simplify some code by removing the return value here.
2015-11-30 13:32:55 -08:00
Slava Pestov
e6d35f29f2 Fix typos I noticed in IRGen and SILGen, NFC 2015-11-30 13:32:55 -08:00
Erik Eckstein
adc92bab45 Compile StdlibUnittest with -sil-serialize-all. 2015-11-30 13:11:00 -08:00
Erik Eckstein
44d2f0ae5e Workaround for a bug in the deserializer (rdar://problem/23620491) 2015-11-30 13:11:00 -08:00
Erik Eckstein
c5c3b176b0 EscapeAnalysis: improve the ConnectionGraph ABI.
Now only those functions are public which are callable from a client.
+ a few other changes.
2015-11-30 13:11:00 -08:00
Erik Eckstein
34bea2c440 EscapeAnalysis: change the handling of use-points.
We can now query if a specific instruction is a use-point.
2015-11-30 13:11:00 -08:00
Erik Eckstein
bd70851769 SIL: Fix mayRelease() for BuiltinInst 2015-11-30 13:11:00 -08:00
Erik Eckstein
461cf5359b tests: Improve comment for StdlibUnittest-import workaround. 2015-11-30 13:11:00 -08:00
Erik Eckstein
966033ac9a EscapeAnalysis: make a separate state for "escapes with return" 2015-11-30 13:11:00 -08:00
Joe Groff
6605b596f3 Absolute-qualify name refs in macro expansion 2015-11-30 12:23:41 -08:00
Daniel Dunbar
5176fea596 [utils/build-script] Pass --xctest override path to SPM build, when building xctest. 2015-11-30 12:14:04 -08:00
Joe Groff
5e5cdc6be3 Runtime: Use 'once' instead of static local variable initialization.
The C++ ABI for static locals is a bit heavy compared to dispatch_once; doing this saves more than 1KB in runtime code size. Dispatch_once/call_once is also more likely to be hot because it's also used by Swift and ObjC code.

Alas, llvm::get_execution_seed() from llvm/ADT/Hashing.h still inflicts one static local initialization on us we can't override (without forking Hashing.h, anyway).
2015-11-30 12:08:12 -08:00
Mishal Awadah
4a11d81e72 [update-checkout] Follow up 32f8492936
Update the local names of XCTest and Foundation.
2015-11-30 11:25:33 -08:00
Argyrios Kyrtzidis
8c6c9a27c1 [sourcekitd] Be tolerant of multiple calls to sourcekitd_initialize. 2015-11-30 10:46:52 -08:00
Argyrios Kyrtzidis
a33319b30d [CMake] Fix "Clang headers were not found" cmake error in a non-standalone build. 2015-11-30 10:32:26 -08:00
Xin Tong
380ddd7e4c [RLE-DSE]. Add NDEBUG and some comments in DSE. NFC 2015-11-30 10:12:16 -08:00
Arnold Schwaighofer
212110ebaa Reapply "Make test independent of function processing order"
This reverts commit 29d6170140.

I missed adding back the REQUIRES line.

Original commit message:

Make test independent of function processing order

This test verifies copy-on-write optimizations based on array semantics happen
correctly.  We test that if SIL has the right form in cowarray_opts.sil these
optimizations happen.  But I believe that it is important to test that SIL has
the right form when we get to the cow hoisting pass. This test verifies this.
Unfortunately, this requires a swift test case.

rdar://23681223
2015-11-30 10:05:29 -08:00
Xin Tong
d81df69b58 [RLE-DSE]. Add some comments about memory location canonicalization in DSE. NFC 2015-11-30 09:51:06 -08:00
Arnold Schwaighofer
29d6170140 Revert "Make test independent of function processing order"
This reverts commit 7f6da3b11e.

This is failing on bots.
2015-11-30 09:41:31 -08:00
Xin Tong
8aea34d45f [RLE-DSE] Refactor and add some comments regarding why ProjectionPath is used in DSE 2015-11-30 09:34:43 -08:00
Xin Tong
3b9945c750 [RLE-DSE] Remove an unneeded parameter in DSE functions 2015-11-30 09:17:31 -08:00
Xin Tong
ae478c020b [RLE-DSE] Update some comments in DSE 2015-11-30 09:06:49 -08:00
Arnold Schwaighofer
7f6da3b11e Make test independent of function processing order
This test verifies copy-on-write optimizations based on array semantics happen
correctly.  We test that if SIL has the right form in cowarray_opts.sil these
optimizations happen.  But I believe that it is important to test that SIL has
the right form when we get to the cow hoisting pass. This test verifies this.
Unfortunately, this requires a swift test case.

rdar://23681223
2015-11-30 08:40:46 -08:00
Tony Parker
32f8492936 Change recommended name of checkout directory for Foundation and XCTest 2015-11-30 08:09:45 -08:00
Nadav Rotem
68aa44b30c Add a document that describes the design of the Swift Optimizer. 2015-11-29 23:08:45 -08:00
Nadav Rotem
f63492f3fa Fix a the description of the CSE pass. 2015-11-29 23:08:45 -08:00
Chris Lattner
0958f67c19 Fix <rdar://problem/22058555> QoI: unhelpful type error "cannot invoke 'withCString' with an argument list of type '((_) -> _)'"
The original issue has long since been fixed, but we were now producing:
error: cannot subscript a value of type 'UnsafePointer<Int8>'

which is pretty obviously wrong.  The problem is that when ranking subscript
decl candidates, CSDiags was using TC.isConvertibleTo to evaluate whether the
actual base type is compatible with the base type of a subscript decl.  This
was failing when the base was generic, because the logic isn't opening
archetypes.  Instead of incorrectly deciding that they are incompatible, just
decide we don't know if an archetype is present.  This allows us to generate
good errors in situation like this.
2015-11-29 22:31:08 -08:00
Chris Lattner
1c592a750f The fix for 23433271 also fixed the crash on 22058555, add its testcase so
we don't regress on it in the future.  Yes, the diagnostic is lousy, I'll
repurpose the second radar to improve it.
2015-11-29 22:15:27 -08:00
Chris Lattner
f4fc002fe2 Fix <rdar://problem/23433271> Swift compiler segfault in failure diagnosis
A crash in CSDiag that happened when we were unconditionally looking at the
getter of a subscript.  This failed on UnsafeMutablePointer because it only
has addressors, not getter/setters.
2015-11-29 22:09:58 -08:00
Chris Lattner
2379928d07 Fix <rdar://22774938> QoI: "never used" in an "if let" should rewrite expression to use != nil
When we see an unused variable in a simple-enough "if/let" (also guard and
while of course), fixit it into a comparison against nil instead of replacing
the name of the variable with "_".  Also special case initialization with an
as? expression, since we can transform that into an "is" boolean test.
2015-11-29 21:49:36 -08:00
Nadav Rotem
5f3f1a31c7 Revert "[Serialization] Fix a bug in the serialization of shared functions."
This reverts commit 422d46638e.

Jordan said that this change is incorrect. I am reverting the patch and plan to
investigate why we are deserializing shared_external functions with no body.
2015-11-29 08:25:44 -08:00
Nadav Rotem
97a793b04f Fix a warning in CSDiag.
The function return value is bool but we were returning a nullptr.
2015-11-29 08:10:45 -08:00
Doug Gregor
63f4f0804e Add a "Contributing" section. 2015-11-28 23:28:39 -08:00
Chris Lattner
4b898cebf2 Fix rdar://23681566, a bug noticed by Marcin Krzyzanowski on twitter where
we would reject an invalid @objc enum with:

<unknown>:0: error: cannot assign value of type '(progress: Int) -> Status' to type 'Status'

because we were poking at the enum element before it was validated.
2015-11-28 22:59:58 -08:00
Chris Lattner
714dcd5ba5 Fix <rdar://problem/23202128> QoI: Poor diagnostic with let vs. var passed to C function
This improves the error message when attempting an array to UnsafeMutablePointer
conversion but where the element type of the array is incorrect or where the array itself
is immutable.

As a bonus fix, this dramatically improves the diagnostic when you pass "&array" to
a function that takes an UnsafePointer.  We decided to not require & in this case, so
we can just provide a nice fixit to rip it off when this common error happens.
2015-11-28 22:13:49 -08:00
Chris Lattner
a7e8eb408d Previous fix was actually for rdar://19478919, correct the testcase. 2015-11-28 21:39:50 -08:00
Chris Lattner
568ed0420e fix <rdar://problem/23271868> QoI: Non-descriptive error message in Swift when passing immutable unsafe pointer instead of mutable
Making diagnostics more specific when using & in a call argument as part of an
Unsafe*Pointer conversion.
2015-11-28 21:38:56 -08:00
Nadav Rotem
0fd81affe1 Remove the verification of cttz & ctlz from the SIL verifier.
This change is related to the effort of enabling the SIL verifier by default in
debug builds.

This commit removes the code that verifies that the second argument of the cttz
and ctlz intrinsics is a constant. The SIL verifier needs to be able to verify
SIL in its early stages before optimizations clean it up. The SIL Verifier
complains that the value 'false' that we pass to ctlz is non-constant. Right now
we don't have a way to pass boolean values to the second parameter of cttz and
ctlz without creating SIL-level control flow. This control flow prevents the
verifier from detecting that the argument is a constant and
verification fails.

I tried to re-write our uses of ctlz using builtins, but the result was cryptic.
I am removing this check from the verifier mainly because it does not contribute
to the safety of our programs.  LLVM already verifies that the last argument is
a constant and I believe that its okay not to verify this trait at SIL level.
2015-11-28 21:16:59 -08:00
Mark Lacey
f181452bbf Remove dead CallGraph parameters.
These parameters were being passed down into getEligibleFunction at one
point, I think to check whether dynamic self was used, but that check
was removed recently so we no longer need to pass this around.
2015-11-28 18:12:51 -08:00
Nadav Rotem
d3b9598f16 Disable the test array_mutable_assertonly.swift
This test greps debug prints from the pass to verify that the optimizations
happen. One problem with this approach is that when we change the order we
process functions in the module the test breaks. Another problem is that the
test only works on specific configurations.

This commit disables the test to allow us to make progress on the bottom-up pass
manager.

rdar://23681223.
2015-11-28 16:47:17 -08:00