Skip to content

Commit ee04c02

Browse files
committed
Add check to catch bug underlying issue #152. Fix will take longer.
1 parent c3c3e03 commit ee04c02

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/boot/be/ra.ml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,20 @@ let reg_alloc
563563
let clobbers = cx.ctxt_abi.Abi.abi_clobbers quad in
564564
let used = quad_used_vregs quad in
565565
let defined = quad_defined_vregs quad in
566+
567+
let vreg_constrs v = (v, Bits.to_list (vreg_constraints.(v))) in
568+
let used_constrs = List.map vreg_constrs used in
569+
let constrs_collide (v1,c1) =
570+
if List.length c1 <> 1
571+
then false
572+
else
573+
List.exists
574+
(fun (v2,c2) -> if v1 = v2 then false else c1 = c2)
575+
used_constrs
576+
in
566577
begin
578+
if List.exists constrs_collide used_constrs
579+
then raise (Ra_error ("over-constrained vregs"));
567580
if List.exists (fun def -> List.mem def clobbers) defined
568581
then raise (Ra_error ("clobber and defined sets overlap"));
569582
iflog cx
@@ -629,7 +642,7 @@ let reg_alloc
629642

630643
with
631644
Ra_error s ->
632-
Session.fail sess "RA Error: %s" s;
645+
Session.fail sess "RA error: %s\n" s;
633646
(quads, 0)
634647

635648
;;

0 commit comments

Comments
 (0)