Skip to content

Commit 904ea18

Browse files
committed
#3247 Fix issue with DUC
1 parent f23c081 commit 904ea18

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

src/psyclone/psyir/tools/definition_use_chains.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def _compute_forward_uses(self, basic_block_list: list[Node]):
629629
# Work out if its read only or not.
630630
assign = reference.ancestor(Assignment)
631631
if reference.ancestor((Call, CodeBlock)):
632-
# Otherwise we assume read/write access for now.
632+
# For calls and Codeblocks we assume read/write access
633633
if defs_out[sig] is not None:
634634
self._killed[sig].append(defs_out[sig])
635635
defs_out[sig] = reference
@@ -930,10 +930,13 @@ def _compute_backward_uses(self, basic_block_list: list[Node]):
930930
sig = reference.get_signature_and_indices()[0]
931931
# Work out if its read only or not.
932932
assign = reference.ancestor(Assignment)
933-
# RHS reads occur "before" LHS writes, so if we
934-
# hit the LHS or an assignment then we won't have
935-
# a dependency to the value used from the LHS.
936-
if assign is not None:
933+
if reference.ancestor(Call):
934+
# For calls and Codeblocks we assume read/write access
935+
defs_out[sig] = reference
936+
elif assign is not None:
937+
# RHS reads occur "before" LHS writes, so if we
938+
# hit the LHS or an assignment then we won't have
939+
# a dependency to the value used from the LHS.
937940
if assign.lhs is reference:
938941
# Check if the RHS contains the self._references.
939942
# Can't use in since equality is not what we want
@@ -981,11 +984,6 @@ def _compute_backward_uses(self, basic_block_list: list[Node]):
981984
# previous assignments.
982985
if defs_out[sig] is None:
983986
self._uses[sig].append(reference)
984-
elif reference.ancestor(Call):
985-
# Otherwise we assume read/write access for now.
986-
if defs_out[sig] is not None:
987-
self._killed[sig].append(defs_out[sig])
988-
defs_out[sig] = reference
989987
else:
990988
# Reference outside an Assignment - read only
991989
# This could be References inside a While loop

src/psyclone/tests/psyir/tools/definition_use_chains_backward_dependence_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,8 @@ def test_definition_use_chain_find_backward_accesses_codeblock_and_call_local(
550550
sig = ref.get_signature_and_indices()[0]
551551
chains = DefinitionUseChain(ref)
552552
reaches = chains.find_backward_accesses()[sig]
553-
# We don't know if the CodeBlock is definitely a write (in this case it
554-
# is not), to the backwards could also be the previous write
555553
assert len(reaches) == 2
556554
assert reaches[0] is routine.walk(CodeBlock)[0].children[0]
557-
assert reaches[1] is routine.walk(Call)[0].arguments[0]
558555

559556

560557
def test_definition_use_chain_find_backward_accesses_call_and_codeblock_nlocal(

0 commit comments

Comments
 (0)