mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-19 15:54:18 +00:00
Add two safety checks whose absence was bug.
Estimated hours taken: 2 value_number: Add two safety checks whose absence was bug. One of these replaces an earlier, inadequate safety check in vn_block. vn_block: Remove that inadequate safety check, since now a more comprehensive one is applied in value_number. opt_util: Opt_util__instr_labels now returns even those labels inside code_addrs. This was needed for value_number. labelopt: Simplify the code based on the new capability of opt_util__instr_labels. dense_switch: Break a too long line.
This commit is contained in:
@@ -207,7 +207,8 @@
|
||||
:- mode opt_util__livevals_addr(in, out) is det.
|
||||
|
||||
% Determine all the labels and code addresses which are referenced
|
||||
% by an instruction.
|
||||
% by an instruction. The code addresses that are labels are returned
|
||||
% in both output arguments.
|
||||
|
||||
:- pred opt_util__instr_labels(instr, list(label), list(code_addr)).
|
||||
:- mode opt_util__instr_labels(in, out, out) is det.
|
||||
@@ -1046,12 +1047,28 @@ opt_util__can_use_livevals(pragma_c(_, _, _, _), no).
|
||||
% determine all the labels and code_addresses that are referenced by Instr
|
||||
|
||||
opt_util__instr_labels(Instr, Labels, CodeAddrs) :-
|
||||
opt_util__instr_labels_2(Instr, Labels, CodeAddrs1),
|
||||
opt_util__instr_labels_2(Instr, Labels0, CodeAddrs1),
|
||||
opt_util__instr_rvals_and_lvals(Instr, Rvals, Lvals),
|
||||
exprn_aux__rval_list_addrs(Rvals, CodeAddrs2, _),
|
||||
exprn_aux__lval_list_addrs(Lvals, CodeAddrs3, _),
|
||||
list__append(CodeAddrs1, CodeAddrs2, CodeAddrs12),
|
||||
list__append(CodeAddrs12, CodeAddrs3, CodeAddrs).
|
||||
list__append(CodeAddrs12, CodeAddrs3, CodeAddrs),
|
||||
opt_util__find_label_code_addrs(CodeAddrs, Labels0, Labels).
|
||||
|
||||
:- pred opt_util__find_label_code_addrs(list(code_addr),
|
||||
list(label), list(label)).
|
||||
:- mode opt_util__find_label_code_addrs(in, in, out) is det.
|
||||
|
||||
% Find out which code addresses are also labels.
|
||||
|
||||
opt_util__find_label_code_addrs([], Labels, Labels).
|
||||
opt_util__find_label_code_addrs([CodeAddr | Rest], Labels0, Labels) :-
|
||||
( CodeAddr = label(Label) ->
|
||||
Labels1 = [Label | Labels0]
|
||||
;
|
||||
Labels1 = Labels0
|
||||
),
|
||||
opt_util__find_label_code_addrs(Rest, Labels1, Labels).
|
||||
|
||||
:- pred opt_util__instr_labels_2(instr, list(label), list(code_addr)).
|
||||
:- mode opt_util__instr_labels_2(in, out, out) is det.
|
||||
|
||||
Reference in New Issue
Block a user