[m-dev.] Re: assertion failure in compiler
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Dec 22 19:06:47 AEDT 2004
On 21-Dec-2004, Julien Fischer <juliensf at cs.mu.OZ.AU> wrote:
> mmc --grade asm_fast.gc -O5 robdd_bug
The cause of the bug is in fact in the loop invariant optimization.
The bug occurs is not restricted to -O5, it also occurs with -O0
--common-struct --loop-invariants. The problem is that --common-struct
optimizes a duplicate TypeClassInfo with an unsafe_cast, and loop
invariant optimization deletes the unsafe_cast (replaces it with true)
as well as the original construction of the TypeClassInfo.
>From then on, the HLDS is invalid, as it uses TypeClassInfo_for_enum_17
without defining it; the code generator just happens to be first pass
to notice the problem. The two relevant procedures (the correct modified
original and its incorrect loop-invariant-exploiting twin) from the
HLDS dump immediately after loop invariant optimization show the problem.
I have a modification to the common-struct optimization that doesn't
cause loop invariant optimization to fail (and generates better code
than we now do besides), but I don't want to commit it until we know
*why* the loop invariant optimization is screwing up with the data it
is given.
Ralph, since you wrote the loop invariant optimization pass, will you
please have a look at the problem?
Zoltan.
% pred id 0
% mode number 0 of predicate `robdd_bug.restrict_true_false_vars_2/4' (det):
% Arg size properties: not_set
% Termination properties: not_set
% variable types map:
% TrueVars0_5 (number 5): (sparse_bitset.sparse_bitset((term.var(T_1))))
% FalseVars0_6 (number 6): (sparse_bitset.sparse_bitset((term.var(T_1))))
% R0_7 (number 7): (robdd_bug.robdd(T_1))
% R_8 (number 8): (robdd_bug.robdd(T_1))
% Var_9 (number 9): (term.var(T_1))
% TrueVars_10 (number 10): (sparse_bitset.sparse_bitset((term.var(T_1))))
% FalseVars_11 (number 11): (sparse_bitset.sparse_bitset((term.var(T_1))))
% V_12 (number 12): (robdd_bug.robdd(T_1))
% TypeInfo_for_T_13 (number 13): (private_builtin.type_info(T_1))
% TypeCtorInfo_14_14 (number 14): (private_builtin.type_ctor_info((term.var(T_1))))
% TypeInfo_15_15 (number 15): (private_builtin.type_info((term.var(T_1))))
% TypeClassInfo_for_enum_16 (number 16): (private_builtin.typeclass_info((private_builtin.constraint((enum.enum), (term.var(T_1))))))
% TypeClassInfo_for_enum_17 (number 17): (private_builtin.typeclass_info((private_builtin.constraint((enum.enum), (term.var(T_1))))))
% TypeCtorInfo_18_18 (number 18): (private_builtin.type_ctor_info((term.var(T_1))))
% TypeInfo_19_19 (number 19): (private_builtin.type_info((term.var(T_1))))
% TypeClassInfo_for_enum_20 (number 20): (private_builtin.typeclass_info((private_builtin.constraint((enum.enum), (term.var(T_1))))))
% TypeClassInfo_for_enum_21 (number 21): (private_builtin.typeclass_info((private_builtin.constraint((enum.enum), (term.var(T_1))))))
% type_info varmap:
% T_1 (number 1) -> type_info(TypeInfo_for_T_13) (number 13)
% typeclass_info varmap:
% address is not taken
:- mode restrict_true_false_vars_2((builtin.in), (builtin.in), (builtin.in), (builtin.in), (builtin.out)) is det.
robdd_bug.restrict_true_false_vars_2(TypeInfo_for_T_13, TrueVars0_5, FalseVars0_6, R0_7, R_8) :-
% context: file `robdd_bug.m', line 46
% nonlocals: TrueVars0_5, FalseVars0_6, R0_7, R_8, TypeInfo_for_T_13
% determinism: det
( % conjunction
% context: file `robdd_bug.m', line 47
% nonlocals: R0_7, Var_9, TypeInfo_for_T_13
% determinism: det
Var_9 = robdd_bug.value(TypeInfo_for_T_13, R0_7)
% pred id: 1, proc id: 0
% unify context: Var_9 = value(R0_7)
,
% nonlocals: TypeCtorInfo_14_14
% determinism: det
TypeCtorInfo_14_14 = type_ctor_info("term", "var", 1)
% TypeCtorInfo_14_14 := <type_ctor_info term.var/1>
% cell_is_unique
,
% nonlocals: TypeInfo_for_T_13, TypeCtorInfo_14_14, TypeInfo_19_19
% determinism: det
TypeInfo_19_19 = type_info_cell_constructor(TypeCtorInfo_14_14, TypeInfo_for_T_13)
% TypeInfo_19_19 := <type_info_cell_constructor> (TypeCtorInfo_14_14, TypeInfo_for_T_13)
% cell_is_unique
,
% nonlocals: TypeClassInfo_for_enum_16
% determinism: det
TypeClassInfo_for_enum_16 = base_typeclass_info("term", class_id(enum.enum, 1), term__var__arity1__)
% TypeClassInfo_for_enum_16 := <base_typeclass_info>
% cell_is_unique
,
% nonlocals: TypeInfo_for_T_13, TypeClassInfo_for_enum_16, TypeClassInfo_for_enum_17, TypeInfo_19_19
% determinism: det
TypeClassInfo_for_enum_17 = typeclass_info_cell_constructor(TypeClassInfo_for_enum_16, TypeInfo_for_T_13, TypeInfo_19_19)
% TypeClassInfo_for_enum_17 := <typeclass_info_cell_constructor> (TypeClassInfo_for_enum_16, TypeInfo_for_T_13, TypeInfo_19_19)
% cell_is_unique
,
% context: file `robdd_bug.m', line 48
% nonlocals: TrueVars0_5, Var_9, TrueVars_10, TypeClassInfo_for_enum_17
% determinism: det
TrueVars_10 = sparse_bitset.remove_leq(TypeClassInfo_for_enum_17, TrueVars0_5, Var_9)
% pred id: 128, proc id: 0
% unify context: TrueVars_10 = sparse_bitset.remove_leq(TrueVars0_5, Var_9)
,
% nonlocals: TypeClassInfo_for_enum_17, TypeClassInfo_for_enum_21
% determinism: det
% unsafe_cast
unsafe_cast(TypeClassInfo_for_enum_17, TypeClassInfo_for_enum_21)
,
% context: file `robdd_bug.m', line 49
% nonlocals: FalseVars0_6, Var_9, FalseVars_11, TypeClassInfo_for_enum_21
% determinism: det
FalseVars_11 = sparse_bitset.remove_leq(TypeClassInfo_for_enum_21, FalseVars0_6, Var_9)
% pred id: 128, proc id: 0
% unify context: FalseVars_11 = sparse_bitset.remove_leq(FalseVars0_6, Var_9)
,
% context: file `robdd_bug.m', line 50
% nonlocals: R0_7, V_12, TypeInfo_for_T_13
% determinism: det
V_12 = robdd_bug.tr(TypeInfo_for_T_13, R0_7)
% pred id: 2, proc id: 0
% unify context: V_12 = tr(R0_7)
,
% context: file `robdd_bug.m', line 50
% nonlocals: R_8, TrueVars_10, FalseVars_11, V_12, TypeInfo_for_T_13, TypeInfo_19_19
% determinism: det
robdd_bug.loop_inv_0__pred__restrict_true_false_vars_2__46__1(TypeInfo_for_T_13, TrueVars_10, FalseVars_11, V_12, R_8, TypeInfo_19_19)
% pred id: 225, proc id: 0
).
% pred id 225
% mode number 0 of predicate `robdd_bug.loop_inv_0__pred__restrict_true_false_vars_2__46__1/6' (det):
% Arg size properties: not_set
% Termination properties: not_set
% variable types map:
% TrueVars0_5 (number 5): (sparse_bitset.sparse_bitset((term.var(T_1))))
% FalseVars0_6 (number 6): (sparse_bitset.sparse_bitset((term.var(T_1))))
% R0_7 (number 7): (robdd_bug.robdd(T_1))
% R_8 (number 8): (robdd_bug.robdd(T_1))
% Var_9 (number 9): (term.var(T_1))
% TrueVars_10 (number 10): (sparse_bitset.sparse_bitset((term.var(T_1))))
% FalseVars_11 (number 11): (sparse_bitset.sparse_bitset((term.var(T_1))))
% V_12 (number 12): (robdd_bug.robdd(T_1))
% TypeInfo_for_T_13 (number 13): (private_builtin.type_info(T_1))
% TypeCtorInfo_14_14 (number 14): (private_builtin.type_ctor_info((term.var(T_1))))
% TypeClassInfo_for_enum_16 (number 16): (private_builtin.typeclass_info((private_builtin.constraint((enum.enum), (term.var(T_1))))))
% TypeClassInfo_for_enum_17 (number 17): (private_builtin.typeclass_info((private_builtin.constraint((enum.enum), (term.var(T_1))))))
% TypeInfo_19_19 (number 19): (private_builtin.type_info((term.var(T_1))))
% TypeClassInfo_for_enum_21 (number 21): (private_builtin.typeclass_info((private_builtin.constraint((enum.enum), (term.var(T_1))))))
% type_info varmap:
% T_1 (number 1) -> type_info(TypeInfo_for_T_13) (number 13)
% typeclass_info varmap:
% address is not taken
:- mode loop_inv_0__pred__restrict_true_false_vars_2__46__1((ground >> ground), (ground >> ground), (ground >> ground), (ground >> ground), (free >> ground), (unique(private_builtin.type_info(unique(<type_ctor_info for term.var/1>), ground)) >> unique(private_builtin.type_info(unique(<type_ctor_info for term.var/1>), ground)))).
robdd_bug.loop_inv_0__pred__restrict_true_false_vars_2__46__1(TypeInfo_for_T_13, TrueVars0_5, FalseVars0_6, R0_7, R_8, TypeInfo_19_19) :-
% context: file `robdd_bug.m', line 46
% nonlocals: TrueVars0_5, FalseVars0_6, R0_7, R_8, TypeInfo_for_T_13, TypeInfo_19_19
% determinism: det
( % conjunction
% context: file `robdd_bug.m', line 47
% nonlocals: R0_7, Var_9, TypeInfo_for_T_13
% determinism: det
Var_9 = robdd_bug.value(TypeInfo_for_T_13, R0_7)
% pred id: 1, proc id: 0
% unify context: Var_9 = value(R0_7)
,
% determinism: det
TypeCtorInfo_14_14 = type_ctor_info("term", "var", 1)
% TypeCtorInfo_14_14 := <type_ctor_info term.var/1>
% cell_is_unique
,
% determinism: det
true
,
% determinism: det
TypeClassInfo_for_enum_16 = base_typeclass_info("term", class_id(enum.enum, 1), term__var__arity1__)
% TypeClassInfo_for_enum_16 := <base_typeclass_info>
% cell_is_unique
,
% determinism: det
true
,
% context: file `robdd_bug.m', line 48
% nonlocals: TrueVars0_5, Var_9, TrueVars_10, TypeClassInfo_for_enum_17
% determinism: det
TrueVars_10 = sparse_bitset.remove_leq(TypeClassInfo_for_enum_17, TrueVars0_5, Var_9)
% pred id: 128, proc id: 0
% unify context: TrueVars_10 = sparse_bitset.remove_leq(TrueVars0_5, Var_9)
,
% nonlocals: TypeClassInfo_for_enum_17, TypeClassInfo_for_enum_21
% determinism: det
% unsafe_cast
unsafe_cast(TypeClassInfo_for_enum_17, TypeClassInfo_for_enum_21)
,
% context: file `robdd_bug.m', line 49
% nonlocals: FalseVars0_6, Var_9, FalseVars_11, TypeClassInfo_for_enum_21
% determinism: det
FalseVars_11 = sparse_bitset.remove_leq(TypeClassInfo_for_enum_21, FalseVars0_6, Var_9)
% pred id: 128, proc id: 0
% unify context: FalseVars_11 = sparse_bitset.remove_leq(FalseVars0_6, Var_9)
,
% context: file `robdd_bug.m', line 50
% nonlocals: R0_7, V_12, TypeInfo_for_T_13
% determinism: det
V_12 = robdd_bug.tr(TypeInfo_for_T_13, R0_7)
% pred id: 2, proc id: 0
% unify context: V_12 = tr(R0_7)
,
% context: file `robdd_bug.m', line 50
% nonlocals: R_8, TrueVars_10, FalseVars_11, V_12, TypeInfo_for_T_13, TypeInfo_19_19
% determinism: det
robdd_bug.loop_inv_0__pred__restrict_true_false_vars_2__46__1(TypeInfo_for_T_13, TrueVars_10, FalseVars_11, V_12, R_8, TypeInfo_19_19)
% pred id: 225, proc id: 0
).
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list