Commit Graph

58361 Commits

Author SHA1 Message Date
Xi Ge
1a32db94cd Merge pull request #30366 from nkcsgexi/59110975
PrintAsObjC: allow users to specify bridging header relative path for printing
2020-03-12 00:30:41 -07:00
Michael Gottesman
1d95b833df Merge pull request #30373 from gottesmm/pr-e0c4ada26f6653e4173eafc1b8c6c7c9c4fa4206
[semantic-arc-opts] Instead of tracking owned value introducers, track incoming values that are seen from owned value introducers.
2020-03-12 00:07:20 -07:00
Shoaib Meenai
b6301c256c Include TargetInfo.h explicitly
https://github.com/llvm/llvm-project/commit/d7c5037e6b9f removes
implicit transitive includes of TargetInfo.h, so we must include it
explicitly where it's needed.
2020-03-11 23:36:59 -07:00
Shoaib Meenai
8b8650770e Include Host.h for getProcessTriple
https://github.com/llvm/llvm-project/commit/213aea4c5836 means this
header doesn't get implicitly transitively included anymore, so we have
to include it explicitly.
2020-03-11 23:36:59 -07:00
Nathan Hawes
2a93296fb6 [SourceKit/CodeFormat] Simplify ContextOverride a little, and only propagate ContextLocs when necessary.
We don't actually need to set a ContextOverride unless the ContextLoc and L
paren/brace/bracket are on different lines. Combined with the fact that we
only set them if the L and R parens/braces/brackets are on different lines
to, it guarantees there will be at most one override that's applicable on
any given line, which lets us simplify the logic somewhat.
2020-03-11 23:06:44 -07:00
Michael Gottesman
faf4519123 [semantic-arc-opts] Instead of tracking owned value introducers, track incoming values that are seen from owned value introducers.
TLDR: This will allow me to in a forthcoming commit to eliminate the extra run
of the peephole optimizer to seed the phi arg analysis since this eliminates
potential data invalidation issues. That being said, I am formalizing the
language/model in the pass a little in this commit, so I wanted to give a long
description below.

----

In this commit, I am formalizing some of the language around this optimization
away phi nodes specifically and more towards a notion that Andy and I have
discussed called "Joined Live Ranges". The idea is a "Live Range" in OSSA is an
owned value together with its set of forwarding uses. The owned value is in a
certain sense the equivalence class representative of all of the values that are
derived from the owned value via forwarding instructions.

This works well as long as all of the "forwarding" instructions only derive
their ownership from a single operand. Some instructions without that property
are branch, tuple, struct. Since such a "forwarding" instruction derives its
ownership by merging the ownership of multiple operands, if multiple of its
operands are non-trivial owned operands, we are in a sense joining together the
live ranges of those non-trivial owned operands. The main implication of this is
that if we want to convert the joined live range from owned to guaranteed, we
can only do it if we can also do it for all of its incoming values at the same
time.

This creates a conundrum though since this pass has been written like a peephole
pass which is ill-suited to be converted into this form. So instead, this pass
seeds an analysis from peephole runs that /could/ have been converted from owned
to guaranteed except for a specific joined live range. Then after we reach a
fixed point, we use that information from the failed peepholes to try to
eliminate the joined live ranges.

This approach is a good approach, but if implemented in certain ways exposes the
risk of problems around touching invalidated data. Specifically, before this
patch, this was implemented with the concern that each branch
instruction (currently the only supported type of joined live range instruction)
could be paired with multiple owned value introducers. This is because
initially, we were allowing for tuple, struct with multiple non-trivial operands
to be used as owned value introducers. This implied that we could not rely on
just storing a bool per joined live range operand since we would need to know
that all introducers associated with the operand were optimizable.

After some thought/discussion, I realized that this sort of optimization can
also apply to tuple/struct/similar insts. This let to the shift in
thinking/realization that we could talk instead about general joined live ranges
and handle tuple/struct/similar instructions just like they were branch/phi! As
such, if we assume that all such instructions are treated as separate
LiveRanges, then we know that our branch can only have a single owned value
introducer since we do not look through /any/ joined live ranges when computing
LiveRanges.

This realization then allows us to store a single bool value marking the operand
on the joined live range as being one that we /may/ be able to optimize. This
then allows us to simplify the state we handle and not have to worry about
storing memory to instructions that may be eliminated. Since we have a joined
live range use, we know that any value that is used by the joined live range can
not be eliminated by the peephole optimizer.
2020-03-11 21:39:46 -07:00
John McCall
585c28d0c3 Plumb a result SILType through SILGen's emitTransformedValue.
This fixes an immediate bug with subst-to-orig conversion of
parameter functions that I'm surprised isn't otherwise tested.
More importantly, it preserves valuable information that should
let us handle a much wider variety of variant representations
that aren't necessarily expressed in the AbstractionPattern.
2020-03-12 00:23:13 -04:00
Hamish Knight
000572d56c Merge pull request #30371 from hamishknight/insider-information
[CS] Use getParameterType for KeyPath as function
2020-03-11 19:32:47 -07:00
omochimetaru
484606dc3a [ConstraintSystem] Fix bug of argument reordering in matchCallArguments 2020-03-12 11:19:28 +09:00
fredriss
80820cc7d6 Merge pull request #30367 from adrian-prantl/sdk-5.3
Adapt to API change that moved Sysroot attribute to CompileUnit
2020-03-11 18:31:43 -07:00
Rintaro Ishizaki
ddaad602d3 Merge pull request #30368 from rintaro/ide-completion-callasfunction-rdar59792682
[CodeCompletion] Support SE-0253 callAsFunction()
2020-03-11 18:16:01 -07:00
Hamish Knight
b62c9b6b01 [CS] Use getParameterType for KeyPath as function
Previously we were using `getPlainType` to match
the parameter type against the key path's base
type. This gave us the external parameter type,
which would be the element type for a variadic
parameter.  However the code we generate expects
the internal parameter type, which is provided by
`getParameterType`.

Resolves rdar://problem/59445486.
2020-03-11 17:21:28 -07:00
Xi Ge
df0493c288 PrintAsObjC: allow users to specify bridging header relative path for printing
Compatibility header may #import bridging header if specified with -import-underlying-module.
How these two headers are relative to each other is subject to project setting. To accommodate
this, we should allow users to specify bridging header directory for header generating purposes.

rdar://59110975
2020-03-11 17:09:53 -07:00
Rintaro Ishizaki
fbc79d2f47 [CodeCompletion] Support SE-0253 callAsFunction()
- In member completions, when 'callAsFunction' decls are found, suggest
  call patterns
- In call pattern completions, fallback to search 'callAsFunction' if
  the base type is not a function type

rdar://problem/59792682
2020-03-11 16:27:27 -07:00
Joe Groff
d06b839c03 Add -verify-all-substitution-maps frontend flag 2020-03-11 16:19:30 -07:00
Joe Groff
23f0d8ccbc Create an inherited conformance in SubstitutionMap::lookupConformance when needed.
If the substituted type for a conformance found via a superclass constraint is a subclass of that
superclass, then we should represent that with an InheritedProtocolConformance rather than with
the original root conformance that applies to the superclass. If we don't do this, then we end up
with spurious inequalities in generic signatures that ought to be equivalent, because some
paths use the inherited conformance and some don't, as in SR-12330 | rdar://problem/60174186.
2020-03-11 16:19:26 -07:00
Doug Gregor
a3979da1cd Merge pull request #30322 from DougGregor/function-builders-extras
[Function builders] Additional entry points
2020-03-11 16:17:27 -07:00
Michael Gottesman
e976aa9071 Merge pull request #29111 from gottesmm/pr-d5a69902a451af42884c0e9cc4b6f18ecf246ada
[passmanager] Change SIL pass pipeline plan to use an LLVM YAML representation.
2020-03-11 16:11:55 -07:00
Michael Gottesman
cdd798bee6 Merge pull request #30319 from gottesmm/pr-9df4a4957e5ff72c67e090d3880070d8cd472328
[semantic-arc-opts] Follow ups to #30289
2020-03-11 16:11:35 -07:00
Raphael Isemann
404cc48475 Adapt to API change that moved Sysroot attribute to CompileUnit
Commit 7b30370e5bcf569fcdc15204d4c592163fd78cb3 changed the Sysroot
attribute to the CompileUnit which broke the build.

(cherry picked from commit 728e8a1bde)
2020-03-11 15:58:46 -07:00
Joe Groff
1cad4a6a3d SILGen: Generate protocol self-conformance substitutions with the self conformance 2020-03-11 15:25:09 -07:00
Joe Groff
f0e61d9a38 Fix bug in SubstitutionMap::verify(), and add check that concrete conformances match concrete types 2020-03-11 15:25:06 -07:00
John McCall
29ff0eaaa0 Merge pull request #30362 from rjmccall/subst-fn-type-interface-sig
Use the right generic signature when producing a substituted function…
2020-03-11 17:31:41 -04:00
Michael Gottesman
52c5f721b9 [passmanager] Change SIL pass pipeline plan to use an LLVM YAML representation.
This eliminates a bunch of code and will make it significantly easier to
maintain/add to this code/use this code.
2020-03-11 14:14:18 -07:00
Slava Pestov
08c4e737db Merge pull request #30361 from slavapestov/witness-table-builder-cleanup
IRGen: Witness table builder cleanup
2020-03-11 16:31:03 -04:00
swift-ci
000928d260 Merge pull request #30360 from CodaFi/results-may-vary 2020-03-11 13:23:10 -07:00
Robert Widmann
d23082ff44 Merge pull request #30359 from CodaFi/unopened-reference-semantics
[CS] Move getUnopenedTypeOfReference out of TypeChecker
2020-03-11 13:11:10 -07:00
Pavel Yaskevich
94ffe9afed Merge pull request #30336 from xedin/adjust-pattern-locators
[CSGen] Clarify locators for some of the patterns
2020-03-11 13:10:26 -07:00
AG
4ac359318b Merge pull request #30344 from bitjammer/acgarland/rdar-59500543-sg-omit-empty-doccomment
[SymbolGraph] Omit empty docComment fields
2020-03-11 13:00:03 -07:00
Xi Ge
a0ad027df8 Merge pull request #30337 from nkcsgexi/walk-around-headers
PrintAsObjc: strip Headers and PrivateHeaders component in header paths explicitly
2020-03-11 12:38:55 -07:00
John McCall
4ee87d4f6d Use the right generic signature when producing a substituted function type from an interface type.
Doing this requires us to re-introduce the concept of the contextual generic signature to SIL type lowering, but hopefully just in a few places.

As the FIXME notes, I found a problem here for substituted function types, but I need to land this first to fix ProcedureKit in the source-compatibility test suite.
2020-03-11 15:25:43 -04:00
Michael Gottesman
09cfcbf50e [semantic-arc-opts] Rename LiveRange::has{,Unknown}ConsumingUse.
We are checking the unknown consuming use vector, so the name makes this clearer
and makes it clear we are not talking about destroying consumers.

I also eliminated the phiToIncomingValueMultiMap being passed in favor of a bool
argument since that is how we are using it today. That was a vestige of an
earlier version of the patch that had to be sunk.
2020-03-11 12:06:12 -07:00
Michael Gottesman
4842e23ed5 [semantic-arc-opts] Rename LiveRange::{general,ownership}ForwardingUse.
This is a clearer name. It is also corresponds with the function
isOwnershipForwardingInst that classifies such operands.
2020-03-11 11:48:46 -07:00
Slava Pestov
84890b6079 IRGen: Move a few things from WitnessTableBuilderBase to FragileWitnessTableBuilder 2020-03-11 14:38:26 -04:00
Slava Pestov
3eb9b15be3 IRGen: Split up WitnessTableBuilder into {Fragile,Resilient}WitnessTableBuilder
This eliminates the need to 'abandon' the initializer for the
fragile witness table, which resilient conformances do not need
or use.
2020-03-11 14:28:55 -04:00
Robert Widmann
266f3ad26f [NFC] Use LookupTypeResult's public API
Drop an extraneous `friend` declaration.
2020-03-11 11:26:45 -07:00
Robert Widmann
4e67eec878 [CS] Move getUnopenedTypeOfReference out of TypeChecker
For some reason, the changed caller in CS wasn't actually going to use any of the types in the constraint system from the entrypoint it was calling. Switch over to using the constraint-system-based entrypoint so we can pick up expression types consistently. Then, move the TypeChecker entrypoint onto ConstraintSystem to reduce the duplication here.

The remaining callers of buildCheckedRefExpr should be migrated.
2020-03-11 11:14:10 -07:00
Slava Pestov
305af0477d IRGen: Split off WitnessTableBuilderBase from WitnessTableBuilder 2020-03-11 14:06:06 -04:00
Andrew Trick
90815f487e Merge pull request #30351 from atrick/fix-escape-assert
AliasAnalysis: add a check for address-type builtin arguments
2020-03-11 09:31:44 -07:00
Andrew Trick
4febc24ec2 Merge pull request #30199 from atrick/fix-struct-let-prop
Disable LetPropertiesOpt on struct 'let's.
2020-03-11 09:28:31 -07:00
Michael Gottesman
fbdf729da6 Merge pull request #30298 from gottesmm/pr-4e1212f1e4e3640e5037f11164d07e20fcea7324
[inliner] Add a new Inliner that only inlines AlwaysInline functions (but do not put it in the pass pipeline).
2020-03-11 01:38:54 -07:00
swift-ci
f16565907d Merge pull request #30350 from gottesmm/pr-72ad962e024d65f236dcbae49c7a0eb2c64c7f83 2020-03-11 00:52:57 -07:00
Michael Gottesman
1c1fae381d Merge pull request #30341 from gottesmm/pr-91997a0048cde708ab0a33c5e524a8c8f9422956
Recommit #30289 with ASAN fix.
2020-03-11 00:43:38 -07:00
swift-ci
f7a26019e7 Merge pull request #30349 from gottesmm/pr-49bb268b53d240a211c7dec15015ad63c779a0bd 2020-03-11 00:26:46 -07:00
Andrew Trick
9bf4386169 AliasAnalysis: add a check for address-type builtin arguments
EscapeAnalysis::mayReleaseContent was recently changed to assert on
address-type arguments. The assert ensures that callers directly pass
the reference being released. If the caller does not have the precise
reference being released, it opens the door to bugs in which the
EscapeAnalysis query looks up the wrong connection graph node.

The original AliasAnalysis logic is just a workaround for the fact
that we don't have information about which builtin's may release
reference-type arguments.

Fixes <rdar://60190962> Escape analysis crashes with "an address is
never a reference" error with -O -thread=sanitize
2020-03-10 23:27:31 -07:00
Michael Gottesman
89f3364444 [gardening] Eliminate passing around of SILBuilders.
This is a bad pattern that we are trying to eliminate from the compiler. On a
side note, this commit also eliminates an unfortunate instance of a raw
SILBuilder!
2020-03-10 23:04:16 -07:00
Michael Gottesman
9c5af74343 [gardening] Eliminate some unneeded llvm:: for types that we already inject into the swift namespace. 2020-03-10 22:46:32 -07:00
Ravi Kandhadai
36deac4fbe [OSLogOptimization] Fix a crash in OSLogOptimization pass that happens
when a SIL address is captured in a closure passed to the log calls.

<rdar://problem/60015040>
2020-03-10 21:42:27 -07:00
Nathan Hawes
aedafe980f [SourceKit/CodeFormat] Improve documentation and fix propagation of ContextLocs.
- Rename several symbols to make it clearer whether the ranges they deal with
  are open or closed.
- Add comments documenting the implementation of OutdentChecker::hasOutdent
- Fix a bug where code after a doc coment block of the '/**' style was being
  indented 1 space.
- Fix IsInStringLiteral not being set if the indent target was in a string
  segment of an interpolated multiline string.
- Update OutdentChecker::hasOutdent to propagate indent contexts from
  parent parens/brackets/braces to child parens/brackets/braces that start
  later in the same line (like FormatWalker already does). This changes the
  braces in the example below to 'inherit' a ContextLoc from their parent
  square brackets, which have a ContextLoc at 'foo'. This makes the whole
  expression be correctly considered 'outdenting':

  foo(a: "hello"
      b: "hello")[x: {
    print("hello")
  }]
2020-03-10 21:04:22 -07:00
Nathan Hawes
1c729ca3e1 [Parse] Fix up a few places where we weren't propagating parse error status correctly.
We were always dropping the error status when returning from parseExprImpl. We
were also incorrectly keeping error status after recovering by finding the
right close token in parseList. This change fixes both, and also updates a few
callers of parseList that assumed when they reported a failure parsing an
element the list as a whole would get error status, which isn't true due to
recovery.
2020-03-10 21:04:22 -07:00