Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2704 backward accesses #2814

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

2704 backward accesses #2814

wants to merge 12 commits into from

Conversation

LonelyCat124
Copy link
Collaborator

Bugs fixed, initial implementation - need to add some other parts to it.

Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.88%. Comparing base (539a5cc) to head (ae099ac).
Report is 16 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2814    +/-   ##
========================================
  Coverage   99.88%   99.88%            
========================================
  Files         357      357            
  Lines       49724    49876   +152     
========================================
+ Hits        49668    49820   +152     
  Misses         56       56            

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

@LonelyCat124 LonelyCat124 marked this pull request as ready for review December 3, 2024 15:34
@LonelyCat124
Copy link
Collaborator Author

@sergisiso This is ready for a first look now I think

Copy link
Collaborator

@sergisiso sergisiso left a comment

Choose a reason for hiding this comment

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

@LonelyCat124 This is in a good shape, all the comments are minor. Some of the logic is quite complicated but since this is self-contained and there are a good amount of tests I am happy with it.

if ref is self._reference:
in_else_body = True
break
# If its in the else_body we don't add the if_body
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe indent this comment as the "break" (and maybe put it before the break)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 458 to 460
"DefinitionUseChains can't "
"handle code containing GOTO"
" statements."
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be condensed to two lines with this indentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

f"must be a Reference but found "
f"'{type(reference).__name__}'.")
raise TypeError(
f"The reference passed into a DefinitionUseChain "
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is from the previous PR, but "The 'reference' argument passed ..." will be clearer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed.

Comment on lines 709 to 711
"DefinitionUseChains can't "
"handle code containing GOTO"
" statements."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make it two lines

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@@ -333,7 +339,12 @@ def find_forward_accesses(self):
# If the control flow node is a Loop we have to check
# if the variable is the same symbol as the _reference.
if isinstance(cfn, Loop):
if cfn.variable == self._reference.symbol:
cfn_abs_pos = cfn.abs_position
Copy link
Collaborator

Choose a reason for hiding this comment

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

From the previous PR, but in the comment above s/could not be taken/could be 'not taken'/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

# This doesn't work correctly if the Reference that
# is having its backwards dependencies analysed occurs after
# one of these such statements in a basic block, however
# since they're unreachable maybe we don't care?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, this is more evidence that we need a DeadCodeEliminationTrans to run early in the process so we get rid of all this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess is this a transformation we'd want to run in the frontend? Or is there a good reason to leave dead code?

self._stop_point = save_stop_position
return self._reaches
else:
# We assume that the control flow here could not be taken,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, maybe its just me but "could not be taken" seems that something when wrong, so maybe "could be 'not taken'" to make clear that we talk about the chain branches?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, changed, that makes more sense.

Comment on lines 987 to 989
# TODO Need to fix this - not sure what is going on here.
# If we get here to check the start part of a loop we need
# to handle this differently.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this still need fixing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, removed the comment.

elif reference.get_signature_and_indices()[0] == sig:
# Work out if its read only or not.
assign = reference.ancestor(Assignment)
# TODO Need to invert how we think about assignments.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this TODO still necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, this works now - removed the comment.

end subroutine'''
psyir = fortran_reader.psyir_from_source(code)
routine = psyir.children[0]
a = routine.children[1].lhs
Copy link
Collaborator

Choose a reason for hiding this comment

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

For clarity maybe call it "a_after_loop" and a_2 call it "a_inside_loop"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually this a_2 was never used so I've now removed it.

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.

2 participants