Skip to content

(closes #3460) Fix issues with recursive datatype copies - #3521

Merged
LonelyCat124 merged 11 commits into
masterfrom
3460_partial_dt_copy_recursion
Aug 5, 2026
Merged

(closes #3460) Fix issues with recursive datatype copies#3521
LonelyCat124 merged 11 commits into
masterfrom
3460_partial_dt_copy_recursion

Conversation

@sergisiso

Copy link
Copy Markdown
Collaborator

No description provided.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a74dfdf) to head (cd36fa9).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3521   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          397       397           
  Lines        55577     55579    +2     
=========================================
+ Hits         55577     55579    +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sergisiso

Copy link
Copy Markdown
Collaborator Author

@LonelyCat124 In addition to the recursive loops I found that copying partial_datatypes was chaning the original tree in some cases, so I added additional copy calls until this was not the case.

I am not sure I fully understand the whole recursive copy path which makes me a bit nervous, but I made the new test quite complete in testing both the consistency of the new copy and that the original remains unchanged (so at least I know that 2 problems currently on master are fixed by this)

@sergisiso

Copy link
Copy Markdown
Collaborator Author

Ah, it failed the integrations, I will look at this next week

@sergisiso

Copy link
Copy Markdown
Collaborator Author

After looking at the failed test I think the input fortran is wrong but it was unexpectedly fixed by copy not working :)

The input for test test_apply_symbol_dependencies is:

        code = (
            "module test_mod\n"
            "contains\n"
            "subroutine main()\n"
            "  real, dimension(10, 10) :: var = 0.0\n"
            "  call sub(var, 10)\n"
            "end subroutine main\n"
            "subroutine sub(x, ilen)\n"
            "  integer, intent(in) :: ilen\n"
            "  real, dimension(ilen, ilen), intent(inout) :: x\n"
            "  real, dimension(ilen, ilen) :: work\n"
            "  type nasty\n"
            "    integer, dimension(ilen+1) :: flag\n"
            "  end type nasty\n"

and once the sub is inlined it becomes:

  subroutine sub(x, ilen)
    integer, intent(in) :: ilen
    real, dimension(ilen,ilen), intent(inout) :: x
    type :: nasty
      integer, dimension(10 + 1) :: flag
    end type nasty

But inlining shouldn't change the original. After fixing the copy behaviour I get:

  subroutine sub(x, ilen)
    integer, intent(in) :: ilen
    real, dimension(ilen,ilen), intent(inout) :: x
    type :: nasty
      integer, dimension(ilen + 1) :: flag
    end type nasty

And it fails to compile with Expression at (1) in this context must be constant

@arporter Can I remove this "nasty" type, or should I replace it with something else?

@arporter

arporter commented Aug 3, 2026

Copy link
Copy Markdown
Member

And it fails to compile with Expression at (1) in this context must be constant

@arporter Can I remove this "nasty" type, or should I replace it with something else?

Ah! I hadn't realised you weren't allowed a dummy argument here. The only other thing I can come up with is a character string with len given by a dummy argument - pls could you try adding that instead of the "nasty" type?

@sergisiso

Copy link
Copy Markdown
Collaborator Author

The len symbols are not processed by inlining, and it results in a dangling symbol, I will attempt to fix it here.

@sergisiso

Copy link
Copy Markdown
Collaborator Author

That's unraveling some more issues:

@sergisiso

Copy link
Copy Markdown
Collaborator Author

@arporter @LonelyCat124 This is finally ready for review, I haven't fixed the inline issues as these already exist before this PR and the fix seems complicated and out of scope here, but I opened issues explaining them.

@LonelyCat124

Copy link
Copy Markdown
Collaborator

I'll take a look after lunch

@LonelyCat124 LonelyCat124 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergisiso One small query, but otherwise this looks fine to me. I'll set ITs running again as well to be safe.

Comment thread src/psyclone/psyir/transformations/inline_trans.py
@sergisiso

Copy link
Copy Markdown
Collaborator Author

@LonelyCat124 This is ready for another look

@LonelyCat124 LonelyCat124 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergisiso Small comment/query about the xfailing test. ITs were otherwise all green so once resolved we can merge.

Comment thread src/psyclone/tests/psyir/transformations/inline_trans_test.py Outdated
@sergisiso

Copy link
Copy Markdown
Collaborator Author

@LonelyCat124 Ready for another look (CI-permitting)

@LonelyCat124 LonelyCat124 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All green now, fixes the original issue - will proceed to merge.

@LonelyCat124
LonelyCat124 merged commit 7e4c7ec into master Aug 5, 2026
16 checks passed
@LonelyCat124
LonelyCat124 deleted the 3460_partial_dt_copy_recursion branch August 5, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants