Skip to content

Conversation

mikeurbach
Copy link
Contributor

We would previously check if the value corresponding to each operand of the ListConcatOp was finished evaluating, but in the case where the operand is a ReferenceValue, the reference may be done evaluating before while the underlying ListValue is not.

To handle this, a check was added that the result of extractList is fully evaluated, and the evaluation of the ListConcatOp doesn't proceed until that is true.

A small unit test shows this scenario, where there are object references in lists passed as field references to a ListConcatOp.

We would previously check if the value corresponding to each operand
of the ListConcatOp was finished evaluating, but in the case where the
operand is a ReferenceValue, the reference may be done evaluating
before while the underlying ListValue is not.

To handle this, a check was added that the result of extractList is
fully evaluated, and the evaluation of the ListConcatOp doesn't
proceed until that is true.

A small unit test shows this scenario, where there are object
references in lists passed as field references to a ListConcatOp.
Copy link
Contributor

@leonardt leonardt left a comment

Choose a reason for hiding this comment

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

LGTM, one comment about the test.

Although I can't see it based on the code shown here, I'm guessing the surrounding context will evaluate these values using a worklist style algorithm until everything is fully evaluated? So that makes returning the unevaluated list work since it will come back around and try again once the dependent values have been evaluated.

auto finalList =
llvm::cast<evaluator::ListValue>(fieldValue.get())->getElements();

ASSERT_EQ(2U, finalList.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it's worth checking the list contents are what we expect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure yeah let me do something with the object references to test that we got the two expected objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a new field to each object so I could check the value of that field in the test.

@mikeurbach
Copy link
Contributor Author

I'm guessing the surrounding context will evaluate these values using a worklist style algorithm until everything is fully evaluated? So that makes returning the unevaluated list work since it will come back around and try again once the dependent values have been evaluated.

Yep that's exactly how it works. You can return a value with the "is fully evaluated" flag set false to indicate that this needs to go back at the end of the worklist.

@mikeurbach mikeurbach merged commit b1f94a5 into main May 2, 2025
5 checks passed
@mikeurbach mikeurbach deleted the mikeurbach/list-concat-partial-cycle branch May 2, 2025 03:51
TaoBi22 pushed a commit to TaoBi22/circt that referenced this pull request Jul 17, 2025
…vm#8460)

We would previously check if the value corresponding to each operand
of the ListConcatOp was finished evaluating, but in the case where the
operand is a ReferenceValue, the reference may be done evaluating
before while the underlying ListValue is not.

To handle this, a check was added that the result of extractList is
fully evaluated, and the evaluation of the ListConcatOp doesn't
proceed until that is true.

A small unit test shows this scenario, where there are object
references in lists passed as field references to a ListConcatOp.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants