Skip to content

Commit

Permalink
Inline: When inlining stmt funcs we also skip explicit intrinsics
Browse files Browse the repository at this point in the history
This caused issue when the following lines attempt to touch the
non-existent procedure definition.
  • Loading branch information
mlange05 committed Dec 16, 2024
1 parent 4c70917 commit e1c8065
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion loki/transformations/inline/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def map_procedure_symbol(self, expr, *args, **kwargs):
return expr.clone(parent=parent)

def map_inline_call(self, expr, *args, **kwargs):
if expr.procedure_type is None or expr.procedure_type is BasicType.DEFERRED:
if expr.procedure_type is None or expr.procedure_type is BasicType.DEFERRED \
or expr.procedure_type.is_intrinsic:
# Unkonw inline call, potentially an intrinsic
# We still need to recurse and ensure re-scoping
return super().map_inline_call(expr, *args, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions loki/transformations/inline/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def test_inline_statement_functions(frontend, stmt_decls):
real :: FOEDELTA
FOEDELTA ( PTARE ) = PTARE + 1.0
real :: FOEEW
FOEEW ( PTARE ) = PTARE + FOEDELTA(PTARE)
FOEEW ( PTARE ) = PTARE + FOEDELTA(PTARE) + EXP(PTARE)
""".strip()

fcode = f"""
Expand All @@ -280,10 +280,10 @@ def test_inline_statement_functions(frontend, stmt_decls):

assert not FindNodes(ir.StatementFunction).visit(routine.spec)
if stmt_decls:
assert not FindInlineCalls().visit(routine.body)
assert len(FindInlineCalls().visit(routine.body)) == 1
assignments = FindNodes(ir.Assignment).visit(routine.body)
assert assignments[0].lhs == 'ret'
assert assignments[0].rhs == "arr + arr + 1.0"
assert assignments[0].rhs == "arr + arr + 1.0 + exp(arr)"
assert assignments[1].lhs == 'ret2'
assert assignments[1].rhs == "3.0 + 1.0"
else:
Expand Down

0 comments on commit e1c8065

Please sign in to comment.