RFR: 8341976: C2: use_mem_state != load->find_exact_control(load->in(0)) assert failure [v7]
Roland Westrelin
roland at openjdk.org
Tue Apr 1 07:31:12 UTC 2025
> The `arraycopy` writes to a non escaping array so its `ArrayCopy` node
> is marked as having a narrow memory effect. One of the loads from the
> destination after the copy is transformed into a load from the source
> array (the rationale being that if there's no load from the
> destination of the copy, the `arraycopy` is not needed). The load from
> the source has the input memory state of the `ArrayCopy` as memory
> input. That load is then sunk out of the loop and its control is
> updated to be after the `ArrayCopy`. That's legal because the
> `ArrayCopy` only has a narrow memory effect and can't modify the
> source. The `ArrayCopy` can't be eliminated and is expanded. In the
> process, a `MemBar` that has a wide memory effect is added. The load
> from the source has control after the membar but memory state before
> and because the membar has a wide memory effect, the load is anti
> dependent on the membar: the graph is broken (the load can't be pinned
> after the membar and anti dependent on it).
>
> In short, the problem is that the graph is transformed under the
> assumption that the `ArrayCopy` has a narrow effect but the
> `ArrayCopy` is expanded to a subgraph that has a wide memory
> effect. The fix I propose is to not insert a membar with a wide memory
> effect. We still need a membar when the destination is non escaping
> because the expanded `ArrayCopy`, if it writes to a tighly allocated
> array, writes to raw memory and not to the destination memory slice.
Roland Westrelin has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 16 additional commits since the last revision:
- review
- Merge branch 'master' into JDK-8341976
- review
- review
- Merge branch 'master' into JDK-8341976
- -XX:+TraceLoopOpts fix
- review
- more
- Merge branch 'master' into JDK-8341976
- more
- ... and 6 more: https://git.openjdk.org/jdk/compare/47f2dbd6...9b21648d
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/23465/files
- new: https://git.openjdk.org/jdk/pull/23465/files/9f79e0b0..9b21648d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=23465&range=06
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=23465&range=05-06
Stats: 8742 lines in 156 files changed: 4824 ins; 3469 del; 449 mod
Patch: https://git.openjdk.org/jdk/pull/23465.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/23465/head:pull/23465
PR: https://git.openjdk.org/jdk/pull/23465
More information about the hotspot-compiler-dev
mailing list