Suppress unused argument warnings in procedures generated by the loop-invariant

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.
This commit is contained in:
Peter Wang
2012-07-25 01:25:16 +00:00
parent 63c3425b14
commit 765f9c6bdc
2 changed files with 12 additions and 0 deletions

View File

@@ -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

View File

@@ -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(_), _, _)
),
% XXX We don't currently generate pragmas for the automatically
% generated class instance methods because the compiler aborts
% when trying to read them back in from the `.opt' files.