Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 823ded11d0caf68359fe9ac511e7c06d8c637e4f
https://github.com/WebKit/WebKit/commit/823ded11d0caf68359fe9ac511e7c06d8c637e4f
Author: Dan Hecht <[email protected]>
Date: 2025-12-10 (Wed, 10 Dec 2025)
Changed paths:
M Source/JavaScriptCore/b3/air/AirAllocateRegistersByGreedy.cpp
M Source/JavaScriptCore/b3/air/AirRegisterAllocatorStats.h
M Source/JavaScriptCore/b3/air/AirUseCounts.h
Log Message:
-----------
[JSC] GreedyRegAlloc: implement intra-block live range splitting
https://bugs.webkit.org/show_bug.cgi?id=303868
rdar://166163403
Reviewed by Marcus Plutowski.
To give the register allocator more options when under register pressure,
implement live range splitting within a basic block. Within a block,
if a Tmp cannot be allocated to a register, then the allocator
attempts to create new Tmps to carry the values within use-def clusters
inside each basic block that the Tmp is accessed. This way, we have
a pattern in a basic block such as:
use Tmp
use Tmp
def Tmp
use Tmp
(in this example, the first cluster has 2 uses of Tmp and the second
cluster has a def and use of Tmp.)
and Tmp spills, currently the allocator will (in the worst case, ignoring
other existing optimizations) rewrite this to:
Mov (spill), r0
use r0
Move (spill), r1
use r1
def r2
Move r2, (spill)
Move (spill), r3
use r3
With intra-block live range splitting, the allocator now has the option
to write this as:
Move (spill), r0
use r0
use r0
def r1
Move r1, (spill) # emitted only if Tmp is live out of the block
use r1
Note that this has some overlap with the fixObviousSpills pass, which
can do a similar transformation when rN==rM, etc. But doing this
at register allocation time can find additional opportunities when
the spill tmps did not happen to get the same register.
Also note that fixObviousSpills can do some additional transformations
such as rewriting constant materializations as Adds and replacing
spill uses with registers across block boundaries. So both are useful.
In the future, this form of live range splitting can be enhanced to
split across loops rather than just intra-block, so spilled
tmps can potentially live in a register for the duration of the loop.
Canonical link: https://commits.webkit.org/304261@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications