mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8240795: [REDO] 8238384 CTW: C2 compilation fails with "assert(store != load->find_exact_control(load->in(0))) failed: dependence cycle found"
Reviewed-by: kvn, thartmann
This commit is contained in:
parent
136a1574ec
commit
c9faf88cb7
5 changed files with 70 additions and 16 deletions
|
@ -1700,8 +1700,9 @@ bool Compile::must_alias(const TypePtr* adr_type, int alias_idx) {
|
||||||
bool Compile::can_alias(const TypePtr* adr_type, int alias_idx) {
|
bool Compile::can_alias(const TypePtr* adr_type, int alias_idx) {
|
||||||
if (alias_idx == AliasIdxTop) return false; // the empty category
|
if (alias_idx == AliasIdxTop) return false; // the empty category
|
||||||
if (adr_type == NULL) return false; // NULL serves as TypePtr::TOP
|
if (adr_type == NULL) return false; // NULL serves as TypePtr::TOP
|
||||||
if (alias_idx == AliasIdxBot) return true; // the universal category
|
// Known instance doesn't alias with bottom memory
|
||||||
if (adr_type->base() == Type::AnyPtr) return true; // TypePtr::BOTTOM or its twins
|
if (alias_idx == AliasIdxBot) return !adr_type->is_known_instance(); // the universal category
|
||||||
|
if (adr_type->base() == Type::AnyPtr) return !C->get_adr_type(alias_idx)->is_known_instance(); // TypePtr::BOTTOM or its twins
|
||||||
|
|
||||||
// the only remaining possible overlap is identity
|
// the only remaining possible overlap is identity
|
||||||
int adr_idx = get_alias_index(adr_type);
|
int adr_idx = get_alias_index(adr_type);
|
||||||
|
|
|
@ -707,19 +707,6 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
|
||||||
// instead of control + memory.
|
// instead of control + memory.
|
||||||
if (mstore->ideal_Opcode() == Op_SafePoint)
|
if (mstore->ideal_Opcode() == Op_SafePoint)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check if the store is a membar on which the load is control dependent.
|
|
||||||
// Inserting an anti-dependency between that membar and the load would
|
|
||||||
// create a cycle that causes local scheduling to fail.
|
|
||||||
if (mstore->isa_MachMemBar()) {
|
|
||||||
Node* dom = load->find_exact_control(load->in(0));
|
|
||||||
while (dom != NULL && dom != dom->in(0) && dom != mstore) {
|
|
||||||
dom = dom->in(0);
|
|
||||||
}
|
|
||||||
if (dom == mstore) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Some raw memory, such as the load of "top" at an allocation,
|
// Some raw memory, such as the load of "top" at an allocation,
|
||||||
// can be control dependent on the previous safepoint. See
|
// can be control dependent on the previous safepoint. See
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "memory/allocation.inline.hpp"
|
#include "memory/allocation.inline.hpp"
|
||||||
#include "memory/resourceArea.hpp"
|
#include "memory/resourceArea.hpp"
|
||||||
#include "opto/addnode.hpp"
|
#include "opto/addnode.hpp"
|
||||||
|
#include "opto/arraycopynode.hpp"
|
||||||
#include "opto/callnode.hpp"
|
#include "opto/callnode.hpp"
|
||||||
#include "opto/connode.hpp"
|
#include "opto/connode.hpp"
|
||||||
#include "opto/convertnode.hpp"
|
#include "opto/convertnode.hpp"
|
||||||
|
@ -4089,8 +4090,16 @@ Node *PhaseIdealLoop::get_late_ctrl( Node *n, Node *early ) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Node *sctrl = has_ctrl(s) ? get_ctrl(s) : s->in(0);
|
Node *sctrl = has_ctrl(s) ? get_ctrl(s) : s->in(0);
|
||||||
|
const TypePtr* adr_type = s->adr_type();
|
||||||
|
if (s->is_ArrayCopy()) {
|
||||||
|
// Copy to known instance needs destination type to test for aliasing
|
||||||
|
const TypePtr* dest_type = s->as_ArrayCopy()->_dest_type;
|
||||||
|
if (dest_type != TypeOopPtr::BOTTOM) {
|
||||||
|
adr_type = dest_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
assert(sctrl != NULL || !s->is_reachable_from_root(), "must have control");
|
assert(sctrl != NULL || !s->is_reachable_from_root(), "must have control");
|
||||||
if (sctrl != NULL && !sctrl->is_top() && C->can_alias(s->adr_type(), load_alias_idx) && is_dominator(early, sctrl)) {
|
if (sctrl != NULL && !sctrl->is_top() && C->can_alias(adr_type, load_alias_idx) && is_dominator(early, sctrl)) {
|
||||||
LCA = dom_lca_for_get_late_ctrl(LCA, sctrl, n);
|
LCA = dom_lca_for_get_late_ctrl(LCA, sctrl, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,6 +452,7 @@ public:
|
||||||
const Type* maybe_remove_speculative(bool include_speculative) const;
|
const Type* maybe_remove_speculative(bool include_speculative) const;
|
||||||
|
|
||||||
virtual bool maybe_null() const { return true; }
|
virtual bool maybe_null() const { return true; }
|
||||||
|
virtual bool is_known_instance() const { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// support arrays
|
// support arrays
|
||||||
|
@ -1397,6 +1398,10 @@ public:
|
||||||
return _ptrtype;
|
return _ptrtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_known_instance() const {
|
||||||
|
return _ptrtype->is_known_instance();
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
|
virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Red Hat, Inc. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 8238384
|
||||||
|
* @summary CTW: C2 compilation fails with "assert(store != load->find_exact_control(load->in(0))) failed: dependence cycle found"
|
||||||
|
*
|
||||||
|
* @run main/othervm -XX:-BackgroundCompilation TestCopyOfBrokenAntiDependency
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class TestCopyOfBrokenAntiDependency {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
for (int i = 0; i < 20_000; i++) {
|
||||||
|
test(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object test(int length) {
|
||||||
|
Object[] src = new Object[length]; // non escaping
|
||||||
|
final Object[] dst = Arrays.copyOf(src, 10); // can't be removed
|
||||||
|
final Object[] dst2 = Arrays.copyOf(dst, 100);
|
||||||
|
// load is control dependent on membar from previous copyOf
|
||||||
|
// but has memory edge to first copyOf.
|
||||||
|
final Object v = dst[0];
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue