Commit Graph

24 Commits

Author SHA1 Message Date
Kavon Farvardin
2caaad0ba2 ColdBlockInfo: post-order walk converges faster
I thought `reverse(silFn)` would do a post-order walk, but I was wrong.

This patch cuts the number of iterations to propagate coldness from
3-4 down to 2 in a few of the simple regression test cases. At least on
macOS (as the stdlib can vary per platform).
2024-09-11 13:27:39 -07:00
Kavon Farvardin
ec622580fd NFC: explain the searchForExpectedValue 2024-09-11 13:15:45 -07:00
Kavon Farvardin
35e426fc26 NFC: fix comment 2024-09-11 11:54:25 -07:00
Kavon Farvardin
3e93a21a21 ColdBlockInfo: stop early if no coldness
There's no reason to do further stages of analysis to propagate coldness
if there wasn't any found in Stage 1.
2024-09-11 11:54:10 -07:00
Kavon Farvardin
7203a4fa73 ColdBlockInfo: overhaul analysis pass
The old analysis pass doesn't take into account profile data, nor does
it consider post-dominance. It primarily dealt with _fastPath/_slowPath.

A block that is dominated by a cold block is itself cold. That's true
whether it's forwards or backwards dominance.

We can also consider a call to any `Never` returning function as a
cold-exit, though the block(s) leading up to that call may be executed
frequently because of concurrency. For now, I'm ignoring the concurrency
case and assuming it's cold. To make use of this "no return" prediction,
use the `-enable-noreturn-prediction` flag, which is currently off by
default.
2024-09-03 15:41:10 -07:00
zoecarver
2ca448b23d Address review comments
* add namespace
* fix block comment style
* SEMA_ATTR -> SEMANTICS_ATTR
* error when SEMANTICS_ATTR isn't defined
2019-11-02 21:58:26 -07:00
zoecarver
9c1a614efb Fix based on review comments 2019-11-02 13:07:20 -07:00
zoecarver
d4129d8659 Add def file for semantics attributes and use constants instead of cstring literals 2019-11-02 11:36:13 -07:00
Arnold Schwaighofer
c187c8ac13 SIL: Replace uses of getReferencedFunction() by getReferencedFunctionOrNull() and getInitialReferencedFunction()
With the advent of dynamic_function_ref the actual callee of such a ref
my vary. Optimizations should not assume to know the content of a
function referenced by dynamic_function_ref. Introduce
getReferencedFunctionOrNull which will return null for such function
refs. And getInitialReferencedFunction to return the referenced
function.
Use as appropriate.

rdar://50959798
2019-05-26 08:58:14 -07:00
Bob Wilson
ef1d9bc7f8 Stop using the _branchHint function
LLVM r355981 changed various intrinsic functions, including expect,
to require immediate arguments. Swift's _branchHint function has an
expected value that is passed in as an argument, so that it cannot
use LLVM's expect intrinsic. The good news is that _branchHint is only
ever used with immediate arguments, so we can just move the intrinsic
into _fastPath and _slowPath and use those instead of _branchHint.

As was noted in the documentation, the _fastPath and _slowPath names are
confusing but we have passed the point where we can simply rename them.
We could add new names but would still need to keep the old ones around
for binary compatibility, and it is not clear that it is worth the
trouble. I have removed that note from the documentation.
2019-03-17 22:13:51 -07:00
Andrew Trick
9d2af79975 Simplify SILPHIArgument::getIncomingValue.
The client of this interface naturally expects to get back the
incoming phi value. Ignoring dominance and SIL ownership, the incoming
phi value and the block argument should be substitutable.

This method was actually returning the incoming operand for
checked_cast and switch_enum terminators, which is deeply misleading
and has been the source of bugs.

If the client wants to peek though casts, and enums, it should do so
explicitly. getSingleTerminatorOperand[s]() will do just that.
2018-08-30 13:01:39 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Erik Eckstein
2e6926cdce Re-format condition in loop. NFC. 2016-02-26 14:05:48 -08:00
Erik Eckstein
3fe19515df Handle more complex conditions in ColdBlockInfo.
Now we can handle the case where the cond_br condition is a block argument.
This change mostly effects the inlining heuristic.

rdar://problem/24777440
2016-02-25 13:31:11 -08:00
Mark Lacey
6a5b25120d Fix 80-column violations in ColdBlockInfo.{h,cpp}. 2016-02-25 13:04:16 -08:00
Michael Gottesman
a5be2fff01 [sil] Use FullApplySite instead of ApplyInst in SILInstruction::getMemoryBehavior().
We were giving special handling to ApplyInst when we were attempting to use
getMemoryBehavior(). This commit changes the special handling to work on all
full apply sites instead of just AI. Additionally, we look through partial
applies and thin to thick functions.

I also added a dumper called BasicInstructionPropertyDumper that just dumps the
results of SILInstruction::get{Memory,Releasing}Behavior() for all instructions
in order to verify this behavior.
2016-02-23 15:00:43 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Michael Gottesman
389238e801 Add support for multiple @_semantics attributes at the SIL level.
This is something that we have wanted for a long time and will enable us to
remove some hacks from the compiler (i.e. how we determine in the ARC optimizer
that we have "fatalError" like function) and also express new things like
"noarc".
2016-01-02 04:17:07 -06:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
22e10737e2 Fix typos 2015-12-26 01:19:40 +01:00
practicalswift
cd7d8dfaff Fix alignment as requested by @gribozavr in #692 2015-12-21 08:54:24 +01:00
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
Andrew Trick
739b0e9c56 Reorganize SILOptimizer directories for better discoverability.
(libraries now)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 15:14:23 -08:00