fortrangoingonforty/armfortas / 784a9e1

Browse files

Mirror driver pipeline in testing.rs (peephole/parallelize/split-bridges/relax-branches)

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
784a9e1c45691989bb389eb4b7efb321234aeace
Parents
d77d39f
Tree
f56dbf5

1 changed file

StatusFile+-
M src/testing.rs 18 0
src/testing.rsmodified
@@ -446,12 +446,30 @@ pub fn capture_from_path(request: &CaptureRequest) -> Result<CaptureResult, Capt
446446
     }
447447
 
448448
     let mut allocated = machine_funcs.clone();
449
+    // Backend peephole at O2+ (must run BEFORE regalloc — it
450
+    // operates on vregs).
451
+    if request.opt_level >= OptLevel::O2 {
452
+        for mf in &mut allocated {
453
+            crate::codegen::peephole::run_peephole(mf);
454
+        }
455
+    }
449456
     for mf in &mut allocated {
450457
         let liveness = crate::codegen::liveness::compute_liveness(mf);
451458
         let result = linearscan::linear_scan(mf);
452459
         linearscan::apply_allocation(mf, &result, &liveness);
460
+        // Post-allocation passes — must mirror the driver pipeline so
461
+        // captured asm matches the binary the user actually ships.
462
+        // parallelize_call_arg_moves in particular fixes a w0/w1
463
+        // clobber pattern visible at high register pressure.
464
+        linearscan::parallelize_entry_arg_moves(mf);
465
+        linearscan::parallelize_call_arg_moves(mf);
466
+        linearscan::insert_split_bridges(mf, &result.split_records);
453467
         linearscan::insert_callee_saves(mf, &result.callee_saved_used);
454468
         linearscan::coalesce_moves(mf);
469
+        if request.opt_level >= OptLevel::O1 {
470
+            crate::codegen::tailcall::tail_call_opt(mf);
471
+        }
472
+        crate::codegen::relax_branches::relax_branches(mf);
455473
     }
456474
     if wants(Stage::Regalloc) {
457475
         stages.insert(