mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-10 03:13:46 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user