Files
mercury/tests/valid/sharing_loop.m
Peter Wang 5b4bc68a32 The definition of `ctgc.selector.subsumed_by' missed cases such as the
Branches: main

The definition of `ctgc.selector.subsumed_by' missed cases such as the
following:

    subsumed_by(ModuleInfo, Sel1, Sel2, Type, Extension)

    Sel1 = [termsel(foo/2, 1)],
    Sel2 = [typesel(bar)]

If the type of the node selected by the term selector in Sel1 is `bar' (the
same as selected by the type selector in Sel2) then it should succeed with
Extension = [].

One symptom was that structure sharing analysis would never reach a fixpoint
analysing some particular SCCs when widening was enabled (which is when type
selectors are introduced).

compiler/ctgc.selector.m:
	Fix `subsumed_by' as above.

tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/sharing_loop.m:
	Add a test case.
2008-06-13 01:22:17 +00:00

66 lines
1.8 KiB
Mathematica

% Regression test. The structure sharing analysis wasn't able to reach a
% fixpoint analysing this module with --structure-sharing-widening set to
% certain values.
:- module sharing_loop.
:- interface.
:- type elds_expr
---> elds_term(var)
; elds_fun(var)
; elds_case_expr(var)
; elds_try(elds_catch).
:- type elds_catch
---> elds_catch(var, elds_expr).
:- type var
---> var(int).
:- type renaming
---> no
; yes(var).
:- pred erl_rename_vars_in_expr(renaming::in,
elds_expr::in, elds_expr::out) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
erl_rename_vars_in_expr(Subn, Expr0, Expr) :-
(
Expr0 = elds_term(Term0),
erl_rename_vars_in_term(Subn, Term0, Term),
Expr = elds_term(Term)
;
Expr0 = elds_fun(Clause0),
erl_rename_vars_in_term(Subn, Clause0, Clause),
Expr = elds_fun(Clause)
;
Expr0 = elds_case_expr(Cases),
Expr = elds_case_expr(Cases)
;
Expr0 = elds_try(Catch0),
erl_rename_vars_in_catch(Subn, Catch0, Catch),
Expr = elds_try(Catch)
).
:- pred erl_rename_vars_in_term(renaming::in,
var::in, var::out) is det.
erl_rename_vars_in_term(no, Var, Var).
erl_rename_vars_in_term(yes(Var), _, Var).
:- pred erl_rename_vars_in_catch(renaming::in,
elds_catch::in, elds_catch::out) is det.
erl_rename_vars_in_catch(Subn, Catch0, Catch) :-
Catch0 = elds_catch(Pattern, Expr0),
erl_rename_vars_in_expr(Subn, Expr0, Expr),
Catch = elds_catch(Pattern, Expr).
%-----------------------------------------------------------------------------%
% vim: ft=mercury ts=8 sts=4 sw=4 et