RFR: JDK-8322854: Incorrect rematerialization of scalar replaced objects in C2 [v4]
Tobias Hartmann
thartmann at openjdk.org
Mon Feb 12 10:57:54 UTC 2024
On Fri, 9 Feb 2024 22:15:21 GMT, Cesar Soares Lucas <cslucas at openjdk.org> wrote:
>> Current implementation of `PhaseMacroExpand::value_from_mem` returns `return _igvn.zerocon(ft);` when it hits a sentinel while searching for a memory operation on a given slice. One of the sentinels is the memory input of the allocate node origin of the memory slice. Therefore, `value_from_mem` may return `zeroconf(ft)` if `sfpt_mem` is the same memory edge used by the Allocate node origin of the memory slice being traversed.
>>
>> The scalar replacement implementation uses `value_from_mem` during creation of metadata describing object scalar replaced (see `PhaseMacroExpand::create_scalarized_object_description`). The `create_scalarized_object_description` method is also used as part of RAM optimization implementation. The RAM optimization targets Phi nodes and therefore a memory graph loop created by a _memory phi_ node is possible to seen as part of the transformation. See image below:
>>
>> <img src="https://github.com/openjdk/jdk/assets/2249648/288681b7-4461-41ea-8dab-bbaebac4727f" height="500" />
>>
>> This pattern doesn't show up when scalarizing objects that don't participate in allocation merges.
>>
>> To fix the issue I changed the code in `value_from_mem` to instead of using the _input_ memory edge of the Allocate as a stop condition, it will now use the projection memory edge of the Allocate.
>>
>> Tested locally on windows, mac and linux x86_64 with JTREG tier1-3 and didn't observe any regression.
>
> Cesar Soares Lucas has updated the pull request incrementally with one additional commit since the last revision:
>
> Adjust test file configs.
The fix looks reasonable to me.
-------------
Marked as reviewed by thartmann (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17562#pullrequestreview-1874981220
More information about the hotspot-compiler-dev
mailing list