Commit Graph

2601 Commits

Author SHA1 Message Date
Joe Shajrawi
403fa0d4aa PGO: Add a profile-based inliner heuristic 2017-09-26 11:10:52 -07:00
Joe Shajrawi
2c03144436 Add support for function_entry_count Profile counter 2017-09-26 11:10:52 -07:00
Joe Shajrawi
72c66cab9a Further cond_br support in the Optimizer: SimplifyCFG and Utils' change target 2017-09-26 11:10:51 -07:00
John McCall
ab3f77baf2 Make SILInstruction no longer a subclass of ValueBase and
introduce a common superclass, SILNode.

This is in preparation for allowing instructions to have multiple
results.  It is also a somewhat more elegant representation for
instructions that have zero results.  Instructions that are known
to have exactly one result inherit from a class, SingleValueInstruction,
that subclasses both ValueBase and SILInstruction.  Some care must be
taken when working with SILNode pointers and testing for equality;
please see the comment on SILNode for more information.

A number of SIL passes needed to be updated in order to handle this
new distinction between SIL values and SIL instructions.

Note that the SIL parser is now stricter about not trying to assign
a result value from an instruction (like 'return' or 'strong_retain')
that does not produce any.
2017-09-25 02:06:26 -04:00
Erik Eckstein
7819a77ad1 SimplifyCFG: limit the number of jump threading through a basic block.
So far we did this only for loop headers, but there are cases where we need it for all blocks to prevent infinite loops in SimplifyCFG.

rdar://problem/34576609
2017-09-21 19:37:22 -07:00
Andrew Trick
c1b9ff7fd9 [sil-opaque-values] Fix FunctionSigOpts for opaque owned-to-guaranteed.
Do not create destroy_addr for opaque values.

Do not create strong_retain/release for opaque types.
2017-09-15 14:08:58 -07:00
Andrew Trick
8cccaddd70 [sil-opaque-values] fix an assert in LowerAggregates. 2017-09-15 14:08:58 -07:00
Andrew Trick
a7bd3136b6 [sil-opaque-values] fix an assert in LowerAggregates. 2017-09-15 14:08:58 -07:00
Michael Gottesman
430f865f73 [inliner] Extract out checking if we can inline from inlineFunction into canInlineFunction. NFC.
The reason to do this is:

1. The check in SILInliner if we can inline can be done without triggering
side-effects.

2. This enables us to know if inlining will succeed before attempting to inline.
This enables for arguments to be adjusted with new SILInstructions and the like
before inlining occurs. I use this in a forthcoming patch that updates mandatory
inlining for ownership.

rdar://31521023
2017-09-08 18:25:57 -07:00
Slava Pestov
70b16e11f9 Fix the build due to a merge conflict 2017-09-07 14:06:38 -07:00
Arnold Schwaighofer
94a5e10dc2 Address review comments 2017-09-06 09:37:00 -07:00
Arnold Schwaighofer
b625d4da8a Osize: Add a SIL Outliner pass that outlines the bridging of objective c calls.
Implements outlining of bridged objective c property and method calls.

rdar://33387700
2017-09-06 08:37:37 -07:00
swift-ci
b765ab7f38 Merge pull request #11741 from shajrawi/revert_deepcopy 2017-09-05 17:31:47 -07:00
Michael Gottesman
e378ad8075 [copy-forwarding] Move a DEBUG log of an instruction to before we destroy the instruction...
Found while debugging dc8b1c2c3a.
2017-09-04 10:49:15 -07:00
Joe Shajrawi
829891b314 Revert "Use emitCopy/Destroy value instead of LoweredCopy/Destroy for large types"
This reverts commit fb1b2a8d9d.
2017-09-01 17:24:58 -07:00
Michael Gottesman
b2550ecb44 [ownership] Do not print out ownership convention on BBArgs once ownership is stripped.
rdar://31521023
2017-08-31 17:53:54 -07:00
Jordan Rose
f8b7db4e76 Excise the terms "blacklist" and "whitelist" from Swift source. (#11687)
The etymology of these terms isn't about race, but "black" = "blocked"
and "white" = "allowed" isn't really a good look these days. In most
cases we weren't using these terms particularly precisely anyway, so
the rephrasing is actually an improvement.
2017-08-30 09:28:00 -07:00
swift-ci
e952c3541b Merge pull request #11676 from shajrawi/explode_large_types_fix 2017-08-29 13:24:06 -07:00
Joe Shajrawi
fb1b2a8d9d Use emitCopy/Destroy value instead of LoweredCopy/Destroy for large types 2017-08-29 12:57:31 -07:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
Jordan Rose
5f30eac288 Excise "Accessibility" from the compiler (1/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the names of methods, fields, a few local
variables, and even a swift-ide-test flag. The full list is below.

accessibilityForDiagnostics -> accessLevelForDiagnostics
checkAccessibility -> checkAccess
checkGenericParamAccessibility -> checkGenericParamAccess
checkTypeAccessibility -> checkTypeAccess
checkWitnessAccessibility -> checkWitnessAccessibility
computeAccessibility -> computeAccessLevel
computeDefaultAccessibility -> computeDefaultAccessLevel
fixItAccessibility -> fixItAccess
getAccessibilityString -> getAccessLevelString
getAccessibilityStrictly -> getAccessLevelStrictly
getAccessibilityUID -> getAccessLevelUID
getActualAccessibility -> getActualAccessLevel
getDefaultAccessibility -> getDefaultAccessLevel
getMaxAccessibility -> getMaxAccessLevel
getOverridableAccessibility -> getOverridableAccessLevel
getRawStableAccessibility -> getRawStableAccessLevel
getSetterAccessibility -> getSetterFormalAccess
hasAccessibility -> hasAccess
hasDefaultAccessibility -> hasDefaultAccessLevel
inferAccessibility -> inferAccessLevel
inferDefaultAccessibility -> inferDefaultAccessLevel
inferSetterAccessibility -> inferSetterAccessLevel
overwriteAccessibility -> overwriteAccess
overwriteSetterAccessibility -> overwriteSetterAccess
printAccessibility -> printAccess
requiredAccessibilityForDiagnostics -> requiredAccessForDiagnostics
resolveAccessibility -> resolveAccessControl
setAccessibility -> setAccess
setSetterAccessibility -> setSetterAccess
setDefaultAndMaxAccessibility -> setDefaultAndMaxAccess
validateAccessibility -> validateAccessControl

Accessibility -> AccessLevel
AccessibilityFilter -> AccessFilter
IgnoreAccessibility -> IgnoreAccessControl
NL_IgnoreAccessibility -> NL_IgnoreAccessControl
PrintAccessibility -> PrintAccess
PrintInternalAccessibilityKeyword -> PrintInternalAccessKeyword
SetterAccessibility -> SetterAccessLevel

setterAccessibility -> setterAccess
storedPropertyAccessibility -> storedPropertyAccess

-print-accessibility -> -print-access
2017-08-28 11:11:57 -07:00
Erik Eckstein
7d359cddfc SimplifyCFG: fix hang caused by infinite loop in CFG
fixes SR-5764, rdar://problem/34068905
2017-08-25 18:03:26 -07:00
Joe Shajrawi
8911d9a0fd Merge pull request #11520 from shajrawi/reduce_explosion
Reduce expansion of large types in the optimizer
2017-08-25 14:19:16 -07:00
Joe Shajrawi
570a82aea5 Reduce expansion of large types in the optimizer 2017-08-25 13:56:26 -07:00
Erik Eckstein
020a283bbb SIL: Let the OpenedArchetypesTracker be constructed with a null SILFunction.
NFC
2017-08-23 09:15:00 -07:00
Roman Levenstein
95223728c2 [sil-inliner] It is always OK to inline a simple call
A simple call is an invocation of a function without any side-effects, where all passed parameters are constants.
2017-08-22 15:16:19 -07:00
Arnold Schwaighofer
1b7a308016 Osize: Only skip inlining for class methods
This addresses most of the regressions from the compat suite and some size
saving gains.
2017-08-18 14:28:32 -07:00
Arnold Schwaighofer
d85b35b588 Tune down inlining at Osize
This is obviously just a start. Don't inline into thunks and don't inline
methods.

Start off with half the benefit for removing a call.
2017-08-17 14:57:22 -07:00
Arnold Schwaighofer
0abf3faa6b Disable function signature optimization at -Osize.
We might be more aggressive here in the future.
2017-08-17 14:57:22 -07:00
Arnold Schwaighofer
64f2d64b54 Disable SpeculativeDevirtualization at -Os 2017-08-17 14:57:22 -07:00
Erik Eckstein
88572a0844 SimplifyCFG: fix a bug which causes SimplifyCFG to hang.
This could happen for CFGs which contain an infinite loop through a switch_enum in the loop header.

rdar://problem/33762217
2017-08-10 17:30:54 -07:00
Erik Eckstein
6c93798acc SILOptimizer: Add a new TempRValue optimization pass
This is a separate optimization that detects short-lived temporaries that can be eliminated.
This is necessary now that SILGen no longer performs basic RValue forwarding in some cases.

SR-5508: Performance regression in benchmarks caused by removing SILGen peephole for LoadExpr in +0 context
2017-08-05 17:23:51 -07:00
swift-ci
e5b6bc1276 Merge remote-tracking branch 'origin/master' into master-next 2017-08-02 15:49:58 -07:00
Roman Levenstein
b83faa0109 [sil-devirtualizer] Fix a bug in devirtualization of methods that never return
This bug was caught by the SIL verifier. Any invocation of a NoReturn function should be followed by an `unreachable` instruction.

Fixes rdar://problem/33591235
2017-08-02 15:14:03 -07:00
swift-ci
0c1ec5f4ed Merge remote-tracking branch 'origin/master' into master-next 2017-08-01 16:48:57 -07:00
Roman Levenstein
5a22424607 [dead-store-elimination] Add support for handling stores to stack promoted objects
Essentially, treat `alloc_ref [stack]` allocated objects in the same way as we treat `alloc_stack` allocated objects.
2017-08-01 15:39:46 -07:00
swift-ci
0a5ee4200a Merge remote-tracking branch 'origin/master' into master-next 2017-07-24 12:48:50 -07:00
Erik Eckstein
6377cc095a SIL: Replace TransitivelyUnreachableBlocks with DeadEndBlocks
We had both utilities doing the same thing.
NFC
2017-07-24 09:50:42 -07:00
Bob Wilson
7ae35833de Merge remote-tracking branch 'origin/master' into master-next 2017-07-21 16:18:54 -07:00
Erik Eckstein
f59c1e4438 StackPromotion: a big simplification of the algorithm
Instead of having the complicated logic of finding the end of an object's lifetime we now use the existing ValueLifetimeAnalysis and StackNesting tools.
This simplifies the implementation a lot and does not use dominator and post-dominator trees anymore.

It's not a NFC because the way how to ensure proper nesting of stack allocations is now different.
To correct the stack nesting, the deallocations are moved down (instead of moving the allocations up).
Also it's now required that there is a final release for the allocation on all paths (which was not the case in some hand-written SIL tests).

Computation of dead-end blocks and escape analysis are now only done on demand. This saves compile time in case a function has no alloc_refs at all.
2017-07-21 13:24:58 -07:00
Erik Eckstein
a0e6082d25 SILOptimizer: change the way how ValueLifetimeAnalysis handles dead-end (unreachable) CFG paths.
In dead-array elimination we assume that the array allocation is post-dominated by all its final releases.
The only exception are branches to dead-end ("unreachable") blocks. So we just ignored all paths which didn't end up in a final release.
Now we explicitly pass the set of dead-end blocks and just ignore those blocks.
This is safer and it's also needed in the upcoming re-write of StackPromotion.
2017-07-21 10:46:03 -07:00
Bob Wilson
62c84a5461 [master-next] Update to work with recent dominator tree changes.
This patch started with a suggestion from Adrian Prantl to adapt to
LLVM r307953. The code has changed more since then so I modified it
to get it to build and I also fixed up StackPromotion to deal with related
changes. (I did not search back very far but it looks like the StackPromotion
change may have been a latent bug that did not matter much until recent
changes started using the function parameter.)
2017-07-19 22:52:21 -07:00
John McCall
4d3e44f98d Update SIL's dominance analysis for the template changes in LLVM.
StackPromotion is still busted.
2017-07-18 17:03:28 -04:00
swift-ci
b1384e5ca1 Merge remote-tracking branch 'origin/master' into master-next 2017-07-18 11:08:50 -07:00
Huon Wilson
994121e3d2 Merge pull request #10861 from huonw/symbol-list-10
TBD: includes all symbols from a full build and test
2017-07-18 10:54:17 -07:00
Huon Wilson
7d843f723c [SILOptimizer] A signature optimized function should have specialized linkage.
Previously this would mean that specialization of a public function are public,
which is incorrect.
2017-07-17 17:33:02 -07:00
Bob Wilson
2fb4f0cae0 master-next: move DEBUG_TYPE macro definition after #includes
LLVM r307950 added a definition of DEBUG_TYPE, followed by an #undef,
in the GenericDomTreeConstruction.h header.
2017-07-14 13:29:42 -07:00
Arnold Schwaighofer
e09abf1341 SimplifyCFG: JumpThread to facilitate ARC removal
It is beneficial to jump thread if we can remove a retain/release pair.

rdar://33099675
SR-5360
2017-07-11 13:43:57 -07:00
Erik Eckstein
c422461527 ArrayElementValuePropagation: Don’t create wrong SIL when trying to optimize ContiguousArray
Instead just bail on ContiguousArray.

https://bugs.swift.org/browse/SR-5293
rdar://problem/32983212
2017-06-28 11:36:39 -07:00
Erik Eckstein
8193b084e4 ARCCodeMotion: fix two problems in release hoisting:
1) PostOrderAnalysis is not invalidated after splitting critical edges. This let the data flow solver omit new inserted blocks.

2) Handle infinite loops in the CFG correctly. So that we don’t insert random release instructions into such CFG pathes.

https://bugs.swift.org/browse/SR-5187
rdar://problem/32713742
2017-06-23 15:20:09 -07:00