Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regalloc: improve printing of equiv. traces #1027

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
process
([PR#989](https://github.com/jasmin-lang/jasmin/pull/989)).

- Incorrect printing of line information in register allocation has been removed
([PR #1027](https://github.com/jasmin-lang/jasmin/pull/1027);
fixes [#1026](https://github.com/jasmin-lang/jasmin/issues/1026)).

## Other changes

- Adding an annotation to function (`'info` type). Useful to store result of analysis. (see [[#1016](https://github.com/jasmin-lang/jasmin/issues/1016)])
Expand Down
13 changes: 10 additions & 3 deletions compiler/src/regalloc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,20 @@ let asm_equality_constraints ~loc pd reg_size asmOp is_move_op (int_of_var: var_
type ('info, 'asm) trace = (int, ('info, 'asm) instr list) Hashtbl.t

let pp_trace pd asmOp (i: int) fmt (tr: ('info, 'asm) trace) =
let j = try Hashtbl.find tr i with Not_found -> [] in
match Hashtbl.find tr i with
| exception Not_found -> ()
| j ->
let pp_i_noloc = Printer.pp_instr ~debug:true pd asmOp in
let pp_i fmt i =
Format.fprintf fmt "@[<v>at %a:@;<1 2>%a@]"
L.pp_iloc i.i_loc
(Printer.pp_instr ~debug:true pd asmOp) i
pp_i_noloc i
in
Format.fprintf fmt "@[<v>%a@]" (pp_list "@ " pp_i) j
let j_noloc, j_loc = List.partition (fun i -> L.isdummy i.i_loc.base_loc) j in
Format.fprintf fmt "@[<v>%a@]" (pp_list "@ " pp_i) j_loc;
if j_noloc <> [] then
Format.fprintf fmt "@;<1 2>and:@;<1 4>@[<v>%a@]"
(pp_list "@ " pp_i_noloc) j_noloc

let normalize_trace (eqc: Puf.t) (tr: ('info, 'asm) instr list array) : ('info, 'asm) trace =
let tbl = Hashtbl.create 97 in
Expand Down