On Wed, 20 May 2026 18:50:13 GMT, Tobias Hartmann <[email protected]> wrote:

>> EA runs a first time, finds a non escaping allocation, splits unique
>> types, creates extra phi nodes, then `LoadFlat` nodes for that
>> allocation are expanded. EA runs a second time. At a `Region`, it
>> finds 2 `Phi` for alias 19:
>> 
>> 1866  Phi  === 1206 1867 1858  [[ 1948 1304 1855 1317 1250 1936 1263 ]]  
>> #memory  Memory: 
>> @aryptr:flat:atomic:instptr:compiler/valhalla/inlinetypes/TestFlatArrayMemoryPhi$MyValue:BotPTR:exact
>>  *,iid=bot[int:2] 
>> (java/lang/Cloneable,java/io/Serializable):NotNull:exact:flat():atomic+any,iid=44,
>>  name=b1, idx=19; !orig=[1208],[1938],[1553],[1239] !jvms: 
>> TestFlatArrayMemoryPhi::test @ bci:34 (line 58)
>> 2073  Phi  === 1206 1149 1858  [[ 1948 2061 ]]  #memory  Memory: 
>> @aryptr:flat:atomic:instptr:compiler/valhalla/inlinetypes/TestFlatArrayMemoryPhi$MyValue:BotPTR:exact
>>  *,iid=bot[int:2] 
>> (java/lang/Cloneable,java/io/Serializable):NotNull:exact:flat():atomic+any,iid=44,
>>  name=b1, idx=19; !orig=2060,[1208],[1938],[1553],[1239] !jvms: 
>> TestFlatArrayMemoryPhi::test @ bci:34 (line 58)
>> 
>> 
>> The first one was created by EA on its first run. The second was
>> created after the first round of EA: it's the result of the
>> transformation of `(Phi (MergeMem ))` into `(MergeMem (Phi ..) (Phi ..)`.
>> 
>> The second `Phi` references another bottom memory `Phi` (1149) and
>> that confuses the logic of EA.
>> 
>> The reason, that second `Phi` is created after EA is that initially
>> the bottom `Phi` has a `LoadFlat` as input but it gets removed because
>> it's from the non escaping allocation and the `Phi`'s input becomes a
>> `MergeMem`. To fix that, I propose that the logic that finds the
>> memory state for a particular alias during EA skips over `LoadFloat`
>> nodes: either a `LoadFloat` is for the current non escaping allocation
>> and it's going away anyway or it's from some other allocation and it's
>> unrelated.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Testing is all clean.

@TobiHartmann thanks for the review and testing

-------------

PR Comment: https://git.openjdk.org/valhalla/pull/2459#issuecomment-4506838357

Reply via email to