Commit Graph

39091 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Kuba (Brecka) Mracek
2dc3390091 Fix IRGen/big_types_corner_cases.swift test for arm64e (#30354) 2020-03-11 10:24:27 -07: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
Michael Gottesman
1c1fae381d Merge pull request #30341 from gottesmm/pr-91997a0048cde708ab0a33c5e524a8c8f9422956
Recommit #30289 with ASAN fix.
2020-03-11 00:43:38 -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
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
a368434432 [SourceKit/CodeFormat] Re-work and improve the indentation implementation.
This restructures the indentation logic around producing a single IndentContext
for the line being indented. An IndentContext has:
- a ContextLoc, which points to a source location to indent relative to,
- a Kind, indicating whether we should align with that location exactly, or
  with the start of the content on its containing line, and
- an IndentLevel with the relative number of levels to indent by.

It also improves the handling of:
- chained and nested parens, braces, square brackets and angle brackets, and
  how those interact with the exact alignment of parameters, call arguments,
  and tuple, array and dictionary elements.
- Indenting to the correct level after an incomplete expression, statement or
  decl.

Resolves:
rdar://problem/59135010
rdar://problem/25519439
rdar://problem/50137394
rdar://problem/48410444
rdar://problem/48643521
rdar://problem/42171947
rdar://problem/40130724
rdar://problem/41405163
rdar://problem/39367027
rdar://problem/36332430
rdar://problem/34464828
rdar://problem/33113738
rdar://problem/32314354
rdar://problem/30106520
rdar://problem/29773848
rdar://problem/27301544
rdar://problem/27776466
rdar://problem/27230819
rdar://problem/25490868
rdar://problem/23482354
rdar://problem/20193017
rdar://problem/47117735
rdar://problem/55950781
rdar://problem/55939440
rdar://problem/53247352
rdar://problem/54326612
rdar://problem/53131527
rdar://problem/48399673
rdar://problem/51361639
rdar://problem/58285950
rdar://problem/58286076
rdar://problem/53828204
rdar://problem/58286182
rdar://problem/58504167
rdar://problem/58286327
rdar://problem/53828026
rdar://problem/57623821
rdar://problem/56965360
rdar://problem/54470937
rdar://problem/55580761
rdar://problem/46928002
rdar://problem/35807378
rdar://problem/39397252
rdar://problem/26692035
rdar://problem/33760223
rdar://problem/48934744
rdar://problem/43315903
rdar://problem/24630624
2020-03-10 21:04:21 -07:00
Michael Gottesman
e3f2bb74d2 [inliner] Add a new Inliner that only inlines AlwaysInline functions (but do not put it in the pass pipeline).
We need this anyways for -Onone and I want to do some experiments with running
this very early so I can expose more of the stdlib (modulo inlining) to the new
ownership optimizing passes.

I also changed how the inliner handles inlining around OSSA by changing it to
check early that if the caller is in ossa, then we only inline if all of the
callees that the caller calls are in ossa. The intention is to hopefully avoid
weird swings in code-size/perf due to the inliner heuristic's calculation being
artificially manipulated due to some callees not being available to inline (due
to this difference) when others are already available.
2020-03-10 19:53:18 -07:00
Ashley Garland
5b6becf186 [SymbolGraph] Omit empty docComment fields
rdar://59500543
2020-03-10 19:37:39 -07:00
Rintaro Ishizaki
04c20b8b62 Merge pull request #30340 from apple/revert-29812-captureconv
Revert "Use in_guaranteed for let captures"
2020-03-10 18:35:45 -07:00
swift-ci
8e39711b35 Merge pull request #30338 from ravikandhadai/oslog-crash-in-unreachable-code 2020-03-10 17:50:48 -07:00
Michael Gottesman
6b88599412 Revert "Merge pull request #30327 from rintaro/revert-30289"
This reverts commit 0a6ccd802f, reversing
changes made to 7c5d74e86b.
2020-03-10 16:52:58 -07:00
Rintaro Ishizaki
ccbc26d947 Revert "Use in_guaranteed for let captures (#29812)"
This reverts commit 13b9915c6f.
2020-03-10 16:08:08 -07:00
Ravi Kandhadai
020c8281c2 [OSLogOptimization] Prevent the OSLogOptimization pass from crashing
when the log calls are invoked in unreachable code.

<rdar://problem/60014600>
2020-03-10 15:48:56 -07:00
Meghana Gupta
13b9915c6f Use in_guaranteed for let captures (#29812)
* Use in_guaranteed for let captures

With this all let values will be captured with in_guaranteed convention
by the closure. Following are the main changes :

SILGen changes:
- A new CaptureKind::Immutable is introduced, to capture let values as in_guaranteed.
- SILGen of in_guaranteed capture had to be fixed.
  in_guaranteed captures as per convention are consumed by the closure. And so SILGen should not generate a destroy_addr for an in_guaranteed capture.
  But LetValueInitialization can push Dealloc and Release states of the captured arg in the Cleanup stack, and there is no way to access the CleanupHandle and disable the emission of destroy_addr while emitting the captures in SILGenFunction::emitCaptures.
  So we now create, temporary allocation of the in_guaranteed capture iduring SILGenFunction::emitCaptures without emitting destroy_addr for it.

SILOptimizer changes:
- Handle in_guaranteed in CopyForwarding.
- Adjust dealloc_stack of in_guaranteed capture to occur after destroy_addr for on_stack closures in ClosureLifetimeFixup.

IRGen changes :
  - Since HeapLayout can be non-fixed now, make sure emitSize is used conditionally
  - Don't consider ClassPointerSource kind parameter type for fulfillments while generating code for partial apply forwarder.
    The TypeMetadata of ClassPointSource kind sources are not populated in HeapLayout's NecessaryBindings. If we have a generic parameter on the HeapLayout which can be fulfilled by a ClassPointerSource, its TypeMetaData will not be found while constructing the dtor function of the HeapLayout.
    So it is important to skip considering sources of ClassPointerSource kind, so that TypeMetadata of a dependent generic parameters gets populated in HeapLayout's NecessaryBindings.
2020-03-10 12:23:02 -07:00
AG
aeabe2884e Merge pull request #30317 from bitjammer/acgarland/rdar-60091161-conditional-conformance
[SymbolGraph] Track conditional conformance
2020-03-10 12:05:41 -07:00
Kuba (Brecka) Mracek
557295686a Mark typeref_lowering.swift and typeref_decoding_imported.swift as UNSUPPORTED for arm64e (#30304) 2020-03-10 11:23:34 -07:00
Kuba (Brecka) Mracek
31593c96c6 Mark ptrauth_generalized_accessors.swift as UNSUPPORTED (#30305) 2020-03-10 11:23:17 -07:00
Kuba (Brecka) Mracek
c728d7a4d2 Fix failing IRGen arm64e tests (#30296) 2020-03-10 11:22:54 -07:00
Pavel Yaskevich
aa35a500a8 Merge pull request #30328 from apple/revert-30164-fix/SR-12290
Revert "[Typechecker] Diagnose key paths with contextual root type but no leading dot"
2020-03-10 11:00:24 -07:00
Rintaro Ishizaki
5405a159df Revert "[test/Index] Add a test case for cross-language USR generation fix on the clang side" 2020-03-10 10:41:25 -07:00
John McCall
81ba9fd223 Merge pull request #30309 from rjmccall/accessor-subst-function-types
Use pattern substitutions to consistently abstract yields
2020-03-10 13:05:28 -04:00
Rintaro Ishizaki
1046516844 Merge pull request #30310 from rintaro/ide-completion-typeexprcall-rdar53516588
[CodeCompletion] Re-typecheck TypeExpr without call arguments
2020-03-10 09:38:18 -07:00
Pavel Yaskevich
e86558fe4f Merge pull request #30277 from LucianoPAlmeida/SR-12019-dynamically-call-generic-constraint
[SR-12019] Fix assert when dynamicallyCall parameter does not satisfy generic constraint
2020-03-10 09:12:33 -07:00
Pavel Yaskevich
2374502a04 Revert "[Typechecker] Diagnose key paths with contextual type but no leading dot (#30164)"
This reverts commit 13487edd09.
2020-03-10 09:06:50 -07:00
Rintaro Ishizaki
fad1b431c2 Revert "[semantic-arc-opts] Implement @owned phi web elimination for phi webs with a single phi node that only have copy_value introducers."
This reverts commit 6fee59bd6a.
2020-03-10 08:43:46 -07:00
Saleem Abdulrasool
77dee318af Merge pull request #30313 from compnerd/archiver
test: add missing tool dependency
2020-03-10 08:10:26 -07:00
Argyrios Kyrtzidis
1082678493 [test/Index] Add a test case for cross-language USR generation fix on the clang side
This is a Swift-side test case for https://github.com/apple/llvm-project/pull/887
Ensures Swift and Clang are in-sync on the USRs for exported properties.
2020-03-09 22:55:28 -07:00
John McCall
07f03bd287 Use pattern substitutions to consistently abstract yields.
The design implemented in this patch is that we lower the types of accessors with pattern substitutions when lowering them against a different accessor, which happens with class overrides and protocol witnesses, and that we introduce pattern substitutions when substituting into a non-patterned coroutine type.  This seems to achieve consistent abstraction without introduce a ton of new complexity.

An earlier version of this patch tried to define witness thunks (conservatively, just for accessors) by simply applying the requirement substitutions directly to the requirement.  Conceptually that should work, but I ran into a lot of trouble with things that assumed that pattern substitutions didn't conceal significant substitution work.  for example, resolving a dependent member in a component type could find a new use of an opaque archetype when the code assumed that such types had already been substituted away.  So while I think that is definiteely a promising direction, I had to back that out in order to make the number of changes manageable for a single PR.

As part of this, I had to fix a number of little bugs here and there, some of which I just introduced.  One of these bugfixes is a place where the substitution code was trying to improperly abstract function types when substituting them in for a type parameter, and it's been in the code for a really long time, and I'm really not sure how it's never blown up before.

I'm increasingly of the opinion that invocation substitutions are not actually necessary, but that --- after we've solved the substitution issues above --- we may want the ability to build multiple levels of pattern substitution so that we can guarantee that e.g. witness thunks always have the exact component structure of the requirement before a certain level of substitution, thus allowing the witness substitutions to be easily extracted.
2020-03-10 01:26:31 -04:00
Michael Gottesman
cee2af0ac9 Merge pull request #30289 from gottesmm/pr-645bd01cfa67ffe64ed23d74e1ee1333fce6ba8a
[semantic-arc-opts] Implement @owned phi web elimination for phi webs with a single phi node that only have copy_value introducers.
2020-03-09 21:55:28 -07:00
Doug Gregor
f0530d0a77 [Function builders] Support buildOptional(_:) in lieu of buildIf(_:).
Line up with the function builders pitch, which uses buildOptional(_:)
to build optional values.
2020-03-09 21:48:15 -07:00
Konrad `ktoso` Malawski
33444489e5 Add _mangledTypeName to allow round trips T->mangledName->T 2020-03-10 12:20:08 +09:00
Ashley Garland
7ce6753231 [SymbolGraph] Track conditional conformance
Requirements on extensions were only being gathered indirectly. This adds a new
optional field to `conformsTo` relationship edges, `swiftConstraints`, which
provides the requirements there.

rdar://60091161
2020-03-09 20:06:49 -07:00
Saleem Abdulrasool
e8bcd90647 test: add missing tool dependency
The tests depend on the archiver, and may opt to use the LLVM archiver.
Add a dependency for the test suite.
2020-03-09 18:47:30 -07:00