[m-rev.] for review: suppress unused arg warnings for loop-inv procedures

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Jul 24 18:20:20 AEST 2012


On Tue, 24 Jul 2012, Peter Wang wrote:

> Branches: main
>
> Suppress unused argument warnings in procedures generated by the loop-invariant
> hoisting pass.
>
> A variable which is determined to be invariant may become unused in the
> auxiliary procedure after invariant goals are deleted, because the variable
> only appears in invariant goals.  It is not that easy to detect such variables
> (I tried) so we rely on the unused argument elimination pass to remove them,
> and suppress the warnings.
>
> compiler/unused_args.m:
> 	As above.
>
> compiler/loop_inv.m:
> 	Add a comment about the unused arguments.
>
> diff --git a/compiler/loop_inv.m b/compiler/loop_inv.m
> index 6725f57..8bc218d 100644
> --- a/compiler/loop_inv.m
> +++ b/compiler/loop_inv.m
> @@ -216,6 +216,11 @@ hoist_loop_invariants(PredProcId, PredInfo, !ProcInfo, !ModuleInfo) :-
>     ->
>         % The set of computed invariant vars is the difference between
>         % the whole invariant var set and the set of invariant args.
> +        %
> +        % Some of these variables may only appear in the invariant goals,
> +        % and would be unused in the auxiliary procedure.  Head variables may
> +        % become unused as well.  We rely on the unused argument elimination
> +        % pass to remove both.
>         ComputedInvVars = InvVars `delete_elems` InvArgs,
>
>         % We need to calculate the initial instmap for the aux proc by applying
> diff --git a/compiler/unused_args.m b/compiler/unused_args.m
> index 23026cd..e8cc943 100644
> --- a/compiler/unused_args.m
> +++ b/compiler/unused_args.m
> @@ -1747,6 +1747,13 @@ output_warnings_and_pragmas(ModuleInfo, UnusedArgInfo, WriteOptPragmas, DoWarn,
>             module_info_get_type_spec_info(ModuleInfo, TypeSpecInfo),
>             TypeSpecInfo = type_spec_info(_, TypeSpecForcePreds, _, _),
>             \+ set.member(PredId, TypeSpecForcePreds),
> +
> +            % Don't warn for a loop-invariant hoisting-generated procedure.
> +            pred_info_get_origin(PredInfo, Origin),
> +            \+ (
> +                Origin = origin_transformed(transform_loop_invariant(_), _, _)
> +            ),
> +

That looks fine, although shouldn't we be suppressing the warning for
all compiler introduced predicates anyway?

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list