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

(0.40) Avoid generating store of uninitialized auto when reducing TRT2 #17605

Merged
merged 1 commit into from Jun 15, 2023

Conversation

jdmpapin
Copy link
Contributor

This is #17546 for 0.40, with the identical commit d33313e.

In the case of a single non-constant delimiter, it's possible for the
pattern to match when the original load and comparison look as follows:

    n56n      istore  elem
    n55n        b2i
    n54n          bloadi <array-shadow>
                    ...
    n60n      istore tmpDelim
    n59n        b2i
    n58n          i2b
    n57n            iload delim
    n65n      ificmpeq --> block_EXIT
    n55n        ==>b2i
    n59n        ==>b2i

With such a match, the booltable node of the pattern graph corresponds
to the ificmpeq node of the target graph. The transformer function for
TRT2 (CISCTransform2FindBytes) finds this target node and from there it
uses the second child as the delimiter, but instead of the b2i that one
might expect, that second child is a variable (tmpDelim) that has been
matched up with the store node (n60n in this example). This situation
results in the transformation generating a load of tmpDelim while at the
same time removing the definition (n60n) that provides the value that is
expected at that load.

This problem should be a pretty rare occurrence. If the tmpDelim store
is dead, it should usually have been eliminated. If OTOH it isn't dead,
then the pattern doesn't match. As such, it would probably be reasonable
to detect this case and simply refuse to transform. However, it's not
necessarily straightforward to detect the problem. I believe that
tableCISCNode->getHeadOfTrNodeInfo()->_node being a store indicates that
the problem is occurring, but it's not obvious that we couldn't see the
same fundamental problem with a load node, or some other node that has a
load as a descendant. With this uncertainty, reliably detecting the
problem case requires walking a subtree and looking for auto loads that
aren't loop-invariant.

Since detecting the problem is already that complex, and since even in
the presence of a store the delimiter might be loop-invariant anyway,
this commit goes slightly further and chases down single definitions to
construct an expression that does not load from autos that are defined
in the loop (if possible). In the example above, that means that we
still remove the tmpDelim store, but now the arraytranslateAndTest node
uses b2i (i2b (iload delim)) instead of iload tmpDelim.
@pshipton pshipton merged commit 71eab61 into eclipse-openj9:v0.40.0-release Jun 15, 2023
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants