Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8282590: C2: assert(addp->is_AddP() && addp->outcnt() > 0) failed: Do…
…n't process dead nodes

Reviewed-by: thartmann, chagedorn
  • Loading branch information
eme64 authored and TobiHartmann committed Mar 22, 2022
1 parent 557ff4b commit d29c7e7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
27 changes: 20 additions & 7 deletions src/hotspot/share/opto/arraycopynode.cpp
Expand Up @@ -189,9 +189,8 @@ Node* ArrayCopyNode::try_clone_instance(PhaseGVN *phase, bool can_reshape, int c
}

MergeMemNode* mem = phase->transform(MergeMemNode::make(in_mem))->as_MergeMem();
PhaseIterGVN* igvn = phase->is_IterGVN();
if (igvn != NULL) {
igvn->_worklist.push(mem);
if (can_reshape) {
phase->is_IterGVN()->_worklist.push(mem);
}

if (!inst_src->klass_is_exact()) {
Expand Down Expand Up @@ -294,9 +293,17 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape,
uint header = arrayOopDesc::base_offset_in_bytes(dest_elem);

src_offset = Compile::conv_I2X_index(phase, src_offset, ary_src->size());
if (src_offset->is_top()) {
// Offset is out of bounds (the ArrayCopyNode will be removed)
return false;
}
dest_offset = Compile::conv_I2X_index(phase, dest_offset, ary_dest->size());
if (src_offset->is_top() || dest_offset->is_top()) {
if (dest_offset->is_top()) {
// Offset is out of bounds (the ArrayCopyNode will be removed)
if (can_reshape) {
// record src_offset, so it can be deleted later (if it is dead)
phase->is_IterGVN()->_worklist.push(src_offset);
}
return false;
}

Expand All @@ -316,9 +323,6 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape,

disjoint_bases = true;

adr_src = phase->transform(new AddPNode(base_src, base_src, src_offset));
adr_dest = phase->transform(new AddPNode(base_dest, base_dest, dest_offset));

BasicType elem = ary_src->klass()->as_array_klass()->element_type()->basic_type();
if (is_reference_type(elem)) {
elem = T_OBJECT;
Expand All @@ -329,6 +333,9 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape,
return false;
}

adr_src = phase->transform(new AddPNode(base_src, base_src, src_offset));
adr_dest = phase->transform(new AddPNode(base_dest, base_dest, dest_offset));

// The address is offseted to an aligned address where a raw copy would start.
// If the clone copy is decomposed into load-stores - the address is adjusted to
// point at where the array starts.
Expand Down Expand Up @@ -566,6 +573,8 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) {
if (!prepare_array_copy(phase, can_reshape,
adr_src, base_src, adr_dest, base_dest,
copy_type, value_type, disjoint_bases)) {
assert(adr_src == NULL, "no node can be left behind");
assert(adr_dest == NULL, "no node can be left behind");
return NULL;
}

Expand Down Expand Up @@ -629,6 +638,10 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) {
}

if (!finish_transform(phase, can_reshape, ctl, mem)) {
if (can_reshape) {
// put in worklist, so that if it happens to be dead it is removed
phase->is_IterGVN()->_worklist.push(mem);
}
return NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/subtypenode.cpp
Expand Up @@ -135,7 +135,7 @@ Node *SubTypeCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
Node* obj = AddPNode::Ideal_base_and_offset(addr, phase, con);
if (con == oopDesc::klass_offset_in_bytes() && obj != NULL) {
assert(is_oop(phase, obj), "only for oop input");
set_req(ObjOrSubKlass, obj);
set_req_X(ObjOrSubKlass, obj, phase);
return this;
}
}
Expand All @@ -144,7 +144,7 @@ Node *SubTypeCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
Node* allocated_klass = AllocateNode::Ideal_klass(obj_or_subklass, phase);
if (allocated_klass != NULL) {
assert(is_oop(phase, obj_or_subklass), "only for oop input");
set_req(ObjOrSubKlass, allocated_klass);
set_req_X(ObjOrSubKlass, allocated_klass, phase);
return this;
}

Expand Down
Expand Up @@ -38,6 +38,19 @@
* compiler.arraycopy.TestArrayCopyAsLoadsStores
*/

/*
* @test
* @bug 8282590
* @library /
*
* @run main/othervm -ea -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestArrayCopyAsLoadsStores::m*
* -XX:TypeProfileLevel=200
* -XX:+IgnoreUnrecognizedVMOptions -XX:+StressArrayCopyMacroNode
* -XX:-TieredCompilation -XX:+StressReflectiveCode -XX:-ReduceInitialCardMarks
* compiler.arraycopy.TestArrayCopyAsLoadsStores
*/

package compiler.arraycopy;

import java.util.Arrays;
Expand Down

3 comments on commit d29c7e7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealMDoerr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d29c7e7 Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealMDoerr the backport was successfully created on the branch TheRealMDoerr-backport-d29c7e74 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d29c7e74 from the openjdk/jdk repository.

The commit being backported was authored by Emanuel Peter on 22 Mar 2022 and was reviewed by Tobias Hartmann and Christian Hagedorn.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev TheRealMDoerr-backport-d29c7e74:TheRealMDoerr-backport-d29c7e74
$ git checkout TheRealMDoerr-backport-d29c7e74
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev TheRealMDoerr-backport-d29c7e74

Please sign in to comment.