RFR: 8332827: [REDO] C2: crash in compiled code because of dependency on removed range check CastIIs [v2]

Emanuel Peter epeter at openjdk.org
Thu Dec 12 07:19:37 UTC 2024


On Wed, 11 Dec 2024 15:04:31 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> src/hotspot/share/opto/compile.cpp line 3147:
>> 
>>> 3145:     DivModNode* divmod = DivModNode::make(n, bt, is_unsigned);
>>> 3146:     divmod->add_prec_from(n);
>>> 3147:     divmod->add_prec_from(d);
>> 
>> Can you explain why you added this?
>
> If the divisor input for a `Div` (or `Mod` etc.) is not not null, then the control input of the `Div` is set to null. It could be that the divisor input is found not null because the subgraph for that input contains a `CastII`. If that happens, removing the `CastII` during final graph reshap could cause the `Div` to float above the `CastII` and above the condition that allowed the type of the `CastII` to be narrowed. This could cause a crash. 
> So when the `CastII` is removed, precedence edges are aded to the `Div` node. If the `Div` is then replaced by a `DivMod`, we need to transfer the precedence edges to the `DivMod` node.

Why not add such a comment to the code then?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22568#discussion_r1881504693


More information about the hotspot-compiler-dev mailing list