@@ -1598,7 +1598,7 @@ impl Assembler {
15981598 }
15991599
16001600 /// Optimize and compile the stored instructions
1601- pub fn compile_with_regs ( self , cb : & mut CodeBlock , regs : Vec < Reg > ) -> Result < ( CodePtr , Vec < CodePtr > ) , CompileError > {
1601+ pub fn compile_with_regs ( self , cb : & mut CodeBlock , mut regs : Vec < Reg > ) -> Result < ( CodePtr , Vec < CodePtr > ) , CompileError > {
16021602 // The backend is allowed to use scratch registers only if it has not accepted them so far.
16031603 let use_scratch_reg = !self . accept_scratch_reg ;
16041604 asm_dump ! ( self , init) ;
@@ -1620,8 +1620,9 @@ impl Assembler {
16201620 }
16211621 }
16221622
1623- trace_compile_phase ( "preferred_registers" , || asm. preferred_register_assignments ( & mut intervals) ) ;
1624- let ( assignments, num_stack_slots) = trace_compile_phase ( "linear_scan" , || asm. linear_scan ( intervals. clone ( ) , regs. len ( ) ) ) ;
1623+ let allocatable_regs = regs. len ( ) ;
1624+ trace_compile_phase ( "preferred_registers" , || asm. preferred_register_assignments ( & mut intervals, & mut regs) ) ;
1625+ let ( assignments, num_stack_slots) = trace_compile_phase ( "linear_scan" , || asm. linear_scan ( intervals. clone ( ) , allocatable_regs, & regs) ) ;
16251626
16261627 asm. stack_state . num_spill_slots = num_stack_slots;
16271628 asm. stack_state . num_side_exit_stack_map_slots = asm. side_exit_stack_map_slots ( & assignments) ;
@@ -1661,8 +1662,8 @@ impl Assembler {
16611662 } ) ;
16621663
16631664 trace_compile_phase ( "resolve_ssa" , || {
1664- asm. handle_caller_saved_regs ( & intervals, & assignments, & C_ARG_REGREGS ) ;
1665- asm. resolve_ssa ( & intervals, & assignments) ;
1665+ asm. handle_caller_saved_regs ( & intervals, & assignments, & regs , & C_ARG_REGREGS ) ;
1666+ asm. resolve_ssa ( & intervals, & assignments, & regs ) ;
16661667 } ) ;
16671668
16681669 Ok ( ( ) )
@@ -1920,10 +1921,10 @@ mod tests {
19201921
19211922 // Assert that only 2 instructions were written.
19221923 assert_disasm_snapshot ! ( cb. disasm( ) , @"
1923- 0x0: adds x0 , x0, x1
1924- 0x4: stur x0 , [x2]
1924+ 0x0: adds x3 , x0, x1
1925+ 0x4: stur x3 , [x2]
19251926 " ) ;
1926- assert_snapshot ! ( cb. hexdump( ) , @"000001ab400000f8 " ) ;
1927+ assert_snapshot ! ( cb. hexdump( ) , @"030001ab430000f8 " ) ;
19271928 }
19281929
19291930 #[ test]
0 commit comments