Commit Graph

58361 Commits

Author SHA1 Message Date
Holly Borla
6bc15293fc [Serialization] Bump the module format version number for serialization
of typeEraser.
2020-02-28 16:46:25 -08:00
Andrew Trick
956948bbee Fix build warning after llvm rebranch: Alignment::operator MaybeAlign() 2020-02-28 16:46:20 -08:00
Rintaro Ishizaki
78d0f6aa4a [CodeCompletion] Primarily use getPossibleCallees() for call signature completion
instead of the pre-typechecked type and the referenced decl in the AST
so that we can suggests all overloads even if it happen to be
typechecked to a method. For example

    struct MyType {
      func foo() {}
      func foo(_ int: Int) {}
      func foo(name: String, value: String) {}
    }
    func test(val: MyType) {
      value.foo(#^COMPLETE^#)
    }

In this case, the call is typechecked to 'MyType.foo(_:)', but we want
to suggest all overloads.

rdar://problem/59285399
2020-02-28 16:44:03 -08:00
Michael Gottesman
c4fe3c225b Merge pull request #30088 from gottesmm/pr-3e6f27334eea2b48b5d8768445143250d4fa13d4
[temp-rvalue] Handle promoting alloc_stack that are destroyed via a load [take] in ossa.
2020-02-28 15:23:54 -08:00
Suyash Srijan
956e918476 [CSSimplify] Move property wrapper fix check after check for conversion restrictions (#30129) 2020-02-28 23:16:32 +00:00
Pavel Yaskevich
389e84fc55 Merge pull request #30115 from LucianoPAlmeida/nfc-abstract-is-stdlib
[NFC] Abstracting isStdlibType and isStdLibDecl logic into Type and Decl
2020-02-28 13:32:32 -08:00
Hamish Knight
0d5a5e12d5 Move #if evaluation flag out of PersistentParserState
Move this flag onto the parser instead. Now the
only client of PersistentParserState is code
completion.
2020-02-28 10:51:12 -08:00
Joe Groff
4abb548adb IRGen: Invoke objc_opt_self directly when available.
We don't need swift_getInitializedObjCClass on new enough Apple OSes because
the ObjC runtime provides an equivalent call for us.
2020-02-28 10:36:42 -08:00
Robert Widmann
d494cc8dcb Merge pull request #30109 from CodaFi/lies-more-lies-and-statistics
[Frontend] Clean Up Usage of UnifiedStatsReporter
2020-02-28 10:24:02 -08:00
Holly Borla
87bb7755c2 Merge pull request #30101 from hborla/dynamic-replacement-type-erasure
[Sema] Implement type erasure for dynamic replacement.
2020-02-28 09:37:33 -08:00
Luciano Almeida
f4b530fb95 [NFC] Abstracting isStdlibType and isStdLibDecl logic into Type and Decl 2020-02-28 07:40:08 -03:00
David Ungar
b8603566fd Merge pull request #30123 from davidungar/fix-overly-conservative-fingerprint-bug
[Incremental] Fix overly conservative fingerprint bug & fix tests.
2020-02-28 01:31:38 -08:00
Pavel Yaskevich
c0b9394c42 Merge pull request #30113 from xedin/rdar-54580247
[CSBindings] Open collection before binding parameter only if origina…
2020-02-28 00:01:27 -08:00
David Ungar
d09c906553 Fix overly conservative fingerprint bug & fix tests. 2020-02-27 23:38:03 -08:00
Doug Gregor
3d9f753f87 Merge pull request #30111 from DougGregor/pattern-implicit-some-harder
[Constraint system] Handle implicit "some" patterns implicitly, better.
2020-02-27 20:57:29 -08:00
swift-ci
0a855a375f Merge pull request #30114 from gottesmm/pr-a9bbea2749a2e9354a42654ce36dd0cacddb4e03 2020-02-27 20:55:00 -08:00
Slava Pestov
ea9806d490 Merge pull request #30097 from slavapestov/sr-75-super-method
Sema: Diagnose unbound method references on 'super.'
2020-02-27 23:06:33 -05:00
Michael Gottesman
63db25e0c7 [ownership] When erroring since we visited an instruction that we should never visit, dump the instruction. 2020-02-27 19:08:34 -08:00
Andrew Trick
631555aa01 Merge pull request #29738 from zoecarver/ossa/let-prop-opt
[ownership] update let properties opts to support ossa
2020-02-27 18:32:02 -08:00
Robert Widmann
a6651a920d Generalize and fix compiler resource freeing before LLVM
Centralize part of the routine that selects which resources to free. Then, add an additional condition for -dump-api-path.

Before, if this option were specified along with -emit-llvm or -c, the compiler would try to rebuild the torn-down ModuleDecl and crash trying to access the torn-down ASTContext.
2020-02-27 17:12:58 -08:00
Robert Widmann
7dd000bdb5 [NFC] Remove the stats reporter parameter from FrontendTool entrypoints
Now that the CompilerInstance owns the stats reporter, use that instead.
2020-02-27 17:12:58 -08:00
Robert Widmann
de72824b04 [Gardening] Canonicalize usages of ASTContext::Stats 2020-02-27 17:12:58 -08:00
Robert Widmann
ccf472d158 [NFC] Clean up performLLVM a bit
The only non-trivial bit is making the DiagnosticEngine parameter to swift::performLLVM required. No callers were taking advantage of this parameter allowing NULL.
2020-02-27 17:12:58 -08:00
Robert Widmann
535bb9bf8f [NFC] UnifiedStatsReporter is owned by CompilerInstance
The lifetime of the UnifiedStatsReporter was not entirely clear from context. Stick it in the CompilerInstance instead so it can live as long as the compile job.

It is critical that its lifetime be extended beyond that of the ASTContext, as the context may be torn down by the time code generation happens, but additional statistics are recorded during LLVM codegen.
2020-02-27 17:12:57 -08:00
Michael Gottesman
3a725c3217 [temp-rvalue] Handle promoting alloc_stack that are destroyed via a load [take] in ossa.
There are a few interesting things here:

1. All of this code is conditionalized implicitly on ossa by us checking for
load [take]. If we are in non-ossa, then we will have unqualified loads and this
code path will be skipped. I left in the old test that made sure we did not
support this in non-ossa code for this purpose.

2. We treat the load [take] like a destroy_addr. Thus the current method of
providing safety via using lifetime analysis to show all "destroys" form a
minimal post-dominating set for the copy_addr.

3. We do not allow for load [take] on sub-element initializations. The reason
why is that SILGen initializes temporaries completely in memory and generally
destroys addresses completely as well. Given that is the pattern we are looking
for, we just reduce the state space by banning this pattern.

4. If we have a copy_addr [init], then we not only change the load [take] to
have the original source address as an argument, but we also change the load
[take] to a load [copy] so we don't lose the +1. Additionally, we have to hoist
the load [copy] to the copy_addr [init] site to ensure that we do not insert a
use-after-free from the retain happening too late.

I am doing this to clean up some simple temp rvalue patterns in SIL before
semantic arc opts runs. This ensures that we are more likely to have a load
operation come from a more meaningful semantic entity (for instance a let field
of a guaranteed class) and thus allow us to convert a load [copy] to a
load_borrow.

I am also going to add support in subsequent commits for eliminating alloc_stack
that are stored into as well (another pattern I am seeing).
2020-02-27 17:09:37 -08:00
Pavel Yaskevich
20fc51d4f4 [CSBindings] Open collection before binding parameter only if original argument type failed
Instead of always opening argument type represented by a collection
without type variables (to support subtyping when element is a labeled tuple),
let's try original type first and if that fails use a slower path with
indirection which attempts `array upcast`. Doing it this way helps to
propagate contextual information faster which fixes a performance regression.

Resolves: rdar://problem/54580247
2020-02-27 16:26:13 -08:00
Doug Gregor
30e8d1791e [Constraint system] Handle implicit "some" patterns implicitly, better.
We have two similar code paths here that should probably be unified. For
now, make sure the more-specific one for pattern matching kicks in first.

Fixes rdar://problem/59838566.
2020-02-27 16:25:02 -08:00
Kuba Mracek
84c4864911 [arm64e] Add Swift compiler support for arm64e pointer authentication 2020-02-27 16:10:31 -08:00
AG
93d700001a Merge pull request #29874 from bitjammer/acgarland/rdar-58339492-sg-source-locations
SymbolGraph: Serialize source locations and doc comment ranges
2020-02-27 15:35:57 -08:00
swift-ci
6b1af597fe Merge pull request #30104 from gottesmm/pr-cc29e3d175061f19a6d6a201fa78c513d626a498 2020-02-27 15:07:31 -08:00
Suyash Srijan
a5241edae9 [MiscDiagnostics] Suppress KVO warning when the property has an explicit setter (#30098) 2020-02-27 22:41:50 +00:00
Slava Pestov
019452f9af Sema: Diagnose unbound method references on 'super.'
This is something I noticed by inspection while working on
<https://bugs.swift.org/browse/SR-75>.

Inside a static method, 'self' is a metatype value, so
'self.instanceMethod' produces an unbound reference of type
(Self) -> (Args...) -> Results.

You might guess that 'super.instanceMethod' can similarly
be used to produce an unbound method reference that calls
the superclass method given any 'self' value, but unfortunately
it doesn't work.

Instead, 'super.instanceMethod' would produce the same
result as 'self.instanceMethod'. Maybe we can implement this
later, but for now, let's just diagnose the problem.

Note that partially-applied method references with 'super.'
-- namely, 'self.staticMethod' inside a static context, or
'self.instanceMethod' inside an instance context, continue
to work as before.

They have the type (Args...) -> Result; since the self value
has already been applied we don't hit the representational
issue.
2020-02-27 17:28:23 -05:00
3405691582
0d3b92dfb1 Swift Basic/Driver recognizes OpenBSD.
Add the platform conditional and set up other basics for the toolchain.

The ConditionalCompilation tests are updated to match, since otherwise
they seem to trip when building on non-OpenBSD platforms. The
Driver/linker test is updated to ensure lld is passed on this platform.
Note that OpenBSD calls "x86_64" as "amd64", so we use that name for the
architecture instead of trying to alias one to the other, as this makes
things simpler.
2020-02-27 17:14:22 -05:00
Michael Gottesman
a45c51e509 [semantic-arc-opts] Add a llvm option to enable verification after each individual peephole for compiler writers.
Just useful for quick triaging.
2020-02-27 13:23:36 -08:00
Varun Gandhi
2dfd5694fa [NFC] Don't crash when we see an empty filename for a module. (#30099)
Fixes rdar://problem/59769612.
2020-02-27 12:58:47 -08:00
Arnold Schwaighofer
869e579477 Merge pull request #30076 from aschwaighofer/silgen_fix_dynamic_replacement_before_original
SILGen: Fix dynamic replacement before original function
2020-02-27 12:03:09 -08:00
Holly Borla
3cdc30ffeb [Sema] Support type erasure for dynamic replacement in function
builders.
2020-02-27 09:01:16 -08:00
Slava Pestov
00318732e1 Merge pull request #30084 from slavapestov/sr-75-prep
More Sema cleanups to prepare for curry thunks
2020-02-27 09:06:38 -05:00
Erik Eckstein
4845d81c64 Temporarily disable mangler verification.
I still need to investigate the failures.
To unblock CI I'm disabling the verification for now.

Failing to correctly remangle a symbol should work, but failing so will not cause any severe damage (miscompile, etc.) in most cases.

rdar://problem/59813007
rdar://problem/59496022
https://bugs.swift.org/browse/SR-12204
2020-02-27 10:26:54 +01:00
swift-ci
8e79687c83 Merge pull request #30093 from gottesmm/pr-0273edba71f32c7d89fa25905b403c3bd0b89667 2020-02-26 23:44:25 -08:00
eeckstein
7b2c8f1c87 Merge pull request #30074 from eeckstein/globalopt
GlobalOpt: improvements for constant folding global variables
2020-02-27 08:30:12 +01:00
Pavel Yaskevich
65ab041805 Merge pull request #29868 from omochi/fix-claimNextNamed
[ConstraintSystem] remove unused computation in claimNextNamed
2020-02-26 22:07:42 -08:00
Michael Gottesman
dae0e44d7c [semantic-arc-opts] When eliminating trivially dead insts exposed by eliminating ARC, explicitly mark madeChange true.
Otherwise, on the face of it we do not invalidate analyses as we should. That
being said, I do not think we actually could hit this in practice today since a
trivially dead instruction can only enter the worklist as a result of us
removing some sort of other instruction causing madeChange to be already true.

That being said, I would rather not rely on that in the face of future
change. Found via site reading code.
2020-02-26 22:05:01 -08:00
Brent Royal-Gordon
222c459fb2 [SE-0274] Stage in #filePath (#29944)
* Stage in #filePath

To give users of #file time to transition, we are first adding #filePath without changing #file’s behavior. This commit makes that change.

Fixes <rdar://problem/58586626>.

* Correct swiftinterface test line
2020-02-27 00:03:13 -06:00
Slava Pestov
9452c60b3b Sema: Remove CSApply's getNaturalArgumentCount() in favor of getNumCurryLevels() 2020-02-26 23:10:07 -05:00
Slava Pestov
90ee606de7 Sema: Refactor CSApply in preparation for curry thunks 2020-02-26 23:10:07 -05:00
Slava Pestov
783ea28f1a AST: Change AutoClosureExpr::isThunk() to getThunkType() 2020-02-26 23:09:54 -05:00
omochimetaru
79a8a596e4 [ConstraintSystem] remove unused computation in claimNextNamed 2020-02-27 10:49:42 +09:00
Joe Groff
7ac3338384 Merge pull request #30058 from jckarter/dont-cache-fixed-class-metadata
IRGen: Don't cache accesses to fixed class metadata.
2020-02-26 17:21:44 -08:00
Michael Gottesman
b7aaad77e5 Merge pull request #30073 from gottesmm/pr-2049c5667508c622325a30f14e18b0c78bb850bf
[ownership] Move TempRValueOpt before Semantic ARC Opts.
2020-02-26 17:15:19 -08:00