mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-13 21:04:00 +00:00
Don't place predicates whose definition is a foreign_proc into the
Estimated hours taken: 2 Branches: main Don't place predicates whose definition is a foreign_proc into the .opt file, if the foreign_proc can't be embedded directly in the generated code as the gain is minimal for the extra complexity in the generated code. compiler/intermod.m: For the il backend, don't export MC++ or C# foreign_procs.
This commit is contained in:
@@ -373,6 +373,11 @@ intermod__should_be_processed(ProcessLocalPreds, PredId, PredInfo,
|
||||
% These will be recreated in the importing module.
|
||||
\+ set__member(PredId, TypeSpecForcePreds),
|
||||
|
||||
% No point exporting code which isn't very inlinable.
|
||||
module_info_globals(ModuleInfo, Globals),
|
||||
globals__get_target(Globals, Target),
|
||||
\+ clauses_contain_noninlinable_foreign_code(Target, Clauses),
|
||||
|
||||
(
|
||||
inlining__is_simple_clause_list(Clauses,
|
||||
InlineThreshold + Arity),
|
||||
@@ -404,6 +409,22 @@ intermod__should_be_processed(ProcessLocalPreds, PredId, PredInfo,
|
||||
pred_info_get_goal_type(PredInfo, promise(_))
|
||||
).
|
||||
|
||||
% If the clauses contains foreign code which requires an external
|
||||
% definition, there is not much point in exporting it.
|
||||
:- pred clauses_contain_noninlinable_foreign_code(compilation_target::in,
|
||||
list(clause)::in) is semidet.
|
||||
|
||||
clauses_contain_noninlinable_foreign_code(Target, [C | _Cs]) :-
|
||||
Target = il,
|
||||
Lang = C ^ clause_lang,
|
||||
Lang = foreign_language(ForeignLang),
|
||||
( ForeignLang = csharp
|
||||
; ForeignLang = managed_cplusplus
|
||||
).
|
||||
clauses_contain_noninlinable_foreign_code(Target, [_ | Cs]) :-
|
||||
clauses_contain_noninlinable_foreign_code(Target, Cs).
|
||||
|
||||
|
||||
:- pred intermod__traverse_clauses(list(clause)::in, list(clause)::out,
|
||||
bool::out, intermod_info::in, intermod_info::out) is det.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user