Commit Graph

2777 Commits

Author SHA1 Message Date
swift-ci
e5ee8f31bb Merge remote-tracking branch 'origin/master' into master-next 2018-03-26 11:03:48 -07:00
Michael Gottesman
86bdc0c0a9 [local] Convert llvm::none_of negative condition => llvm::all_of positive condition.
Outside of the actual function in question this is NFC.
2018-03-26 10:46:17 -07:00
Michael Gottesman
9001d1029f [local] Change some for-loops in analyzeStaticInitializer to use llvm::none_of.
Noticed this while trying to understand the code in global opt that uses this. I
also did a little style cleanup in the function.

NFC.
2018-03-24 14:58:20 -07:00
swift-ci
d9d63fd702 Merge remote-tracking branch 'origin/master' into master-next 2018-03-19 23:07:30 -07:00
Michael Gottesman
e567bc9028 [+0-all-args] Enable +0 normal arguments.
rdar://34222540
2018-03-19 20:25:31 -07:00
swift-ci
7fb186fece Merge remote-tracking branch 'origin/master' into master-next 2018-03-11 23:29:00 -07:00
Andrew Trick
9703d56e03 [exclusivity] Remove dead access markers after optimization.
Generalized to handle scope markers which will become common with future
ownership and lifetime dependence markers.
2018-03-11 23:13:30 -07:00
swift-ci
ecd7a48bb2 Merge remote-tracking branch 'origin/master' into master-next 2018-03-09 09:49:07 -08:00
Arnold Schwaighofer
1e4f55de8d Merge pull request #15046 from aschwaighofer/without_actually_escaping_verification
Implement withoutActuallyEscaping verification
2018-03-09 09:34:06 -08:00
swift-ci
52a9d71e70 Merge remote-tracking branch 'origin/master' into master-next 2018-03-08 01:49:10 -08:00
Sho Ikeda
cea6c03eb2 [gardening] Use !empty() over size() > 0 2018-03-08 09:21:09 +09:00
Arnold Schwaighofer
5940796cc1 SIL: Add an is_escaping_closure instruction
Will be used to verify that withoutActuallyEscaping's block does not
escape the closure.

``%escaping = is_escaping_closure %closure`` tests the reference count. If the
closure is not uniquely referenced it prints out and error message and
returns true. Otherwise, it returns false. The returned result can be
used with a ``cond_fail %escaping`` instruction to abort the program.

rdar://35525730
2018-03-07 08:56:00 -08:00
swift-ci
938927f04b Merge remote-tracking branch 'origin/master' into master-next 2018-03-05 12:09:02 -08:00
Arnold Schwaighofer
390ba419fc Add an effects(releasenone) function effects attribute
A ``@effects(releasenone)`` function might read/write global state but does not
perform a release.
2018-03-05 07:03:54 -08:00
swift-ci
1e8c4087e8 Merge remote-tracking branch 'origin/master' into master-next 2018-03-01 13:50:50 -08:00
Michael Gottesman
7dc017cc60 Teach the generic specializer how to convert @in_guaranteed parameters to @guaranteed parameters.
We already do this for @in parameters. I think it was just never implemented for
@in_guaranteed. The reason I am doing this now is that a bunch of test cases
that tested @in -> trivial. By doing this I get the @in_guaranteed -> trivial
implying those test cases do not need to be updated.

Important Note: We have bad test cases for resilience when dealing with generic specializer. Also add correct test cases + change existing ones

Note2: We only support this for trivial in_guaranteed types
2018-03-01 10:44:35 -08:00
swift-ci
25459d7aff Merge remote-tracking branch 'origin/master' into master-next 2018-02-26 15:48:53 -08:00
swift-ci
984dafe55b Merge pull request #14840 from shajrawi/concat_thin 2018-02-26 15:33:55 -08:00
Joe Shajrawi
2314df3db5 Handle 'thin' callees in extractStringConcatOperands 2018-02-26 14:35:48 -08:00
swift-ci
e6620914e1 Merge remote-tracking branch 'origin/master' into master-next 2018-02-21 13:17:22 -08:00
swift-ci
d468dcb108 Merge pull request #14767 from adrian-prantl/37720555 2018-02-21 13:10:45 -08:00
Adrian Prantl
9b6a9946ec Be explicit about whether a DebugInfo-carying SILInstruction has debug info.
This patch both makes debug variable information it optional on
alloc_stack and alloc_box instructions, and forced variable
information on debug_value and debug_value_addr instructions. The
change of the interface uncovered a plethora of bugs in SILGen,
SILTransform, and IRGen's LoadableByAddress pass.

Most importantly this fixes the previously commented part of the
DebugInfo/local-vars.swift.gyb testcase.

rdar://problem/37720555
2018-02-21 10:50:19 -08:00
swift-ci
68fd7acc8f Merge remote-tracking branch 'origin/master' into master-next 2018-02-20 08:09:54 -08:00
Joe Shajrawi
b0fdadb3d2 Devirtualizer: disable the “effectively final” optimization if a function is inlinable.
The devirtualizer performs two optimizations:

- If a value is known to have an exact class type, ie it is the result of an alloc_ref, we can devirtualize calls of *non-final* methods, because we know we’re calling that specific method and not an override.

- If a method is known to be “effectively final” (it is not open, and there are no overrides inside the module) we can devirtualize it.

However the second optimization needs to be disabled if a function is inlinable (F->getResilienceExpansion() == ResilienceExpansion::Minimal).
2018-02-20 16:06:01 +02:00
swift-ci
beae25974d Merge remote-tracking branch 'origin/master' into master-next 2018-02-14 05:29:28 -08:00
Arnold Schwaighofer
a9fa8c9c2b Merge pull request #14514 from aschwaighofer/wip_closure_capture_abi_part2
WIP: Closure ABI - Make @noescape Swift closures trivial
2018-02-14 05:19:25 -08:00
swift-ci
130d44650b Merge remote-tracking branch 'origin/master' into master-next 2018-02-13 07:49:32 -08:00
Joe Shajrawi
102b6f0b61 Merge pull request #14587 from shajrawi/newinstr
Optimizer peephole for tagged BridgeObjects
2018-02-13 07:38:53 -08:00
Arnold Schwaighofer
a71dff2c06 PerformanceInlinerUtils: Support convert_escape_to_noescape instructions 2018-02-13 04:19:59 -08:00
Arnold Schwaighofer
9e9c29c133 Utils: Add assert 2018-02-13 04:19:59 -08:00
Arnold Schwaighofer
0c16e21a3d MandatoryInlining: Teach the inliner/tryToDeleteDeadClosure about noescape casts 2018-02-13 04:19:59 -08:00
Joe Shajrawi
f732ea66ef Builtins: add ValueToBridgeObject instruction 2018-02-12 13:27:59 +02:00
swift-ci
089fdec180 Merge remote-tracking branch 'origin/master' into master-next 2018-02-10 17:49:21 -08:00
Mark Lacey
d63bb3fc53 Remove most uses of OptionalTypeKind.
What remains are places where we are conflating optionality with
either nullability or failability.
2018-02-10 16:24:09 -08:00
swift-ci
f31db98c4f Merge remote-tracking branch 'origin/master' into master-next 2018-02-07 05:29:51 -08:00
Arnold Schwaighofer
d51053b003 Add convert_escape_to_noescape instruction for converting escaping to noescape functions
@noescape function types will eventually be trivial. A
convert_escape_to_noescape instruction does not take ownership of its
operand. It is a projection to the trivial value carried by the closure
-- both context and implementation function viewed as a trivial value.

A safe SIL program must ensure that the object that the project value is based
on is live beyond the last use of the trivial value. This will be
achieve by means of making the lifetimes dependent.

For example:

  %e = partial_apply [callee_guaranteed] %f(%z) : $@convention(thin) (Builtin.Int64) -> ()
  %n = convert_escape_to_noescape %e : $@callee_guaranteed () -> () to $@noescape @callee_guaranteed () -> ()
  %n2 = mark_dependence %n : $@noescape @callee_guaranteed () -> () on %e : $@callee_guaranteed () -> ()
  %f2 = function_ref @use : $@convention(thin) (@noescape @callee_guaranteed () -> ()) -> ()
  apply %f2(%n2) : $@convention(thin) (@noescape @callee_guaranteed () -> ()) -> ()
  release_value %e : $@callee_guaranteed () -> ()

Note: This is not yet actually used.

Part of:
SR-5441
rdar://36116691
2018-02-06 18:01:23 -08:00
swift-ci
67e4edf809 Merge remote-tracking branch 'origin/master' into master-next 2018-02-06 06:09:32 -08:00
Mark Lacey
b4b66bc8e8 Replace getAnyOptionalObjectType with getOptionalObjectType. 2018-02-05 23:59:00 -08:00
swift-ci
dad2f3ae8d Merge remote-tracking branch 'origin/master' into master-next 2018-02-05 18:48:57 -08:00
Andrew Trick
113bebb035 Centralize logic for access marker and exclusivity verification.
Create helpers in InstructionUtils.h wherever we need a guarantee that the diagnostics cover the same patterns as the verifier. Eventually this will be called from both SILVerifier and the diagnostic pass:
- findAccessedAddressBase
- isPossibleFormalAccessBase
- isPartialApplyOfReabstractionThunk
- findClosureForAppliedArg
- visitAccessedAddress

Add partial_apply verification assert.

This applies the normal "find a closure" logic inside the "find all partial_apply uses" verification. Making the verifier round-trip ensures that we don't have holes in exclusivity enforcement related to this logic.
2018-02-05 18:43:30 -08:00
swift-ci
2ef8ac84c8 Merge remote-tracking branch 'origin/master' into master-next 2018-01-24 20:49:34 -08:00
Erik Eckstein
f06fcd268b cast optimizer: don't create a critical edge where it's not allowed
https://bugs.swift.org/browse/SR-6773
rdar://problem/36602263
2018-01-24 16:56:48 -08:00
swift-ci
cd1290e155 Merge remote-tracking branch 'origin/master' into master-next 2018-01-19 15:09:18 -08:00
Erik Eckstein
44aafd950c Tuning the inliner heuristics:
* allow small class methods to be inlined with -Osize
* inline pure calls: references to objects, which are initialized with constants, are considered as constant arguments
2018-01-19 11:32:37 -08:00
Erik Eckstein
bf87035a36 GlobalOpt: Move the object outlining from GlobalOpt into a separate pass "ObjectOutliner"
We run GlobalOpt multiple times in the pass pipeline but in some cases object outlining shouldn't be done too early.
Having it done in a separate pass enables to run it independently from GlobalOpt.
2018-01-19 11:32:36 -08:00
Erik Eckstein
41c2991f6c Move the constant folding logic into a separate utility which can be used by multiple passes.
NFC
2018-01-19 11:29:35 -08:00
swift-ci
05ee3d9c9e Merge remote-tracking branch 'origin/master' into master-next 2018-01-18 23:49:59 -08:00
eeckstein
b126b62256 Revert "Optimization changes to completely fold OptionSet literals" 2018-01-18 22:05:07 -08:00
swift-ci
d55a655ced Merge remote-tracking branch 'origin/master' into master-next 2018-01-18 19:50:14 -08:00
Erik Eckstein
8fb523e776 Tuning the inliner heuristics:
* allow small class methods to be inlined with -Osize
* inline pure calls: references to objects, which are initialized with constants, are considered as constant arguments
2018-01-18 18:27:17 -08:00