1
CS553 Lecture Register Allocation II 2
More Register Allocation
Last time
– Register allocation – Global allocation via graph coloring
Today
More Register Allocation Last time Register allocation Global - - PDF document
More Register Allocation Last time Register allocation Global allocation via graph coloring Today More register allocation Clarifications from last time Finish improvements on basic graph coloring concept Procedure
Last time
Today
Move instructions
Idea
Problem
Rule
Idea
Why is this a good idea?
Idea
Easy case
Examples
Fastest to slowest
Interference Allocators
Problem
Two approaches
Goals
Complicating Issues
Partition registers into two categories
Caller-saved registers
Example foo()
Callee-saved registers
Example
Insensitive register allocation
Sensitive register allocation
Use precolored nodes
Add architectural registers to interference graph
Express allocation constraints
Callee-saved registers
Caller-saved registers
r1, r2 caller-saved r3 callee-saved
Callee-saved registers
The larger “problem”
Wouldn’t it be nice to. . .
Compile-time interprocedural register allocation?
Link-time interprocedural re-allocation?
Overall strategy
Compiler does local allocation & planning for linker
Linker does interprocedural allocation & patches compiled code
Describe code patch if particular variable allocated to a register
Usage
w := (x + y) * z
w := y++ * z
Problem
More actions
LOAD(var)
STORE(var)
w := x := y++ * z
Steps
Use profile data to construct weights Do global register allocation at compile-time Track liveness information for variables at each call site Track intraprocedural interference graph Use real interference graph at link-time
Machine: DEC WRL Titan RISC processor (64 registers) Basic experiment
Improvements
Benefit decreases with number of link-time registers Link-time better than global register allocation
Delayed decision making
Dynamic compilation requires fast register allocation
Performance results
Simple solutions can work well
Delayed decision making
Modern environments change the rules
Register allocation and procedure calls Calling conventions
Interprocedural analysis
Register allocation in a JIT