Skip to content

Commit c9baa8a

Browse files
committed
8352418: Add verification code to check that the associated loop nodes of useless Template Assertion Predicates are dead
Reviewed-by: epeter, roland
1 parent b80b04d commit c9baa8a

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/hotspot/share/opto/predicates.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,46 @@ void EliminateUselessPredicates::mark_useful_predicates_for_loop(IdealLoopTree*
12401240
void EliminateUselessPredicates::mark_maybe_useful_predicates_useless() const {
12411241
mark_maybe_useful_predicates_on_list_useless(_parse_predicates);
12421242
mark_maybe_useful_predicates_on_list_useless(_template_assertion_predicate_opaques);
1243+
DEBUG_ONLY(verify_loop_nodes_of_useless_templates_assertion_predicates_are_dead();)
12431244
}
12441245

1246+
#ifdef ASSERT
1247+
// All now useless Template Assertion Predicates should not refer to any CountedLoopNode that can still be found in the
1248+
// graph (otherwise, they would have been marked useful instead). This is verified in this method.
1249+
void EliminateUselessPredicates::verify_loop_nodes_of_useless_templates_assertion_predicates_are_dead() const {
1250+
ResourceMark rm;
1251+
Unique_Node_List loop_nodes_of_useless_template_assertion_predicates =
1252+
collect_loop_nodes_of_useless_template_assertion_predicates();
1253+
verify_associated_loop_nodes_are_dead(loop_nodes_of_useless_template_assertion_predicates);
1254+
}
1255+
1256+
Unique_Node_List EliminateUselessPredicates::collect_loop_nodes_of_useless_template_assertion_predicates() const {
1257+
Unique_Node_List loop_nodes_of_useless_template_assertion_predicates;
1258+
for (int i = 0; i < _template_assertion_predicate_opaques.length(); i++) {
1259+
OpaqueTemplateAssertionPredicateNode* opaque_node = _template_assertion_predicate_opaques.at(i);
1260+
if (opaque_node->is_useless()) {
1261+
loop_nodes_of_useless_template_assertion_predicates.push(opaque_node->loop_node());
1262+
}
1263+
}
1264+
return loop_nodes_of_useless_template_assertion_predicates;
1265+
}
1266+
1267+
void EliminateUselessPredicates::verify_associated_loop_nodes_are_dead(
1268+
const Unique_Node_List& loop_nodes_of_useless_template_assertion_predicates) const {
1269+
if (loop_nodes_of_useless_template_assertion_predicates.size() == 0) {
1270+
return;
1271+
}
1272+
for (LoopTreeIterator iterator(_ltree_root); !iterator.done(); iterator.next()) {
1273+
IdealLoopTree* loop = iterator.current();
1274+
Node* loop_head = loop->head();
1275+
if (loop_head->is_CountedLoop()) {
1276+
assert(!loop_nodes_of_useless_template_assertion_predicates.member(loop_head),
1277+
"CountedLoopNode should be dead when found in OpaqueTemplateAssertionPredicateNode being marked useless");
1278+
}
1279+
}
1280+
}
1281+
#endif // ASSERT
1282+
12451283
template<class PredicateList>
12461284
void EliminateUselessPredicates::mark_maybe_useful_predicates_on_list_useless(
12471285
const PredicateList& predicate_list) const {

src/hotspot/share/opto/predicates.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,11 @@ class EliminateUselessPredicates : public StackObj {
12541254
template <class PredicateList>
12551255
void mark_maybe_useful_predicates_on_list_useless(const PredicateList& predicate_list) const;
12561256

1257+
#ifdef ASSERT
1258+
void verify_loop_nodes_of_useless_templates_assertion_predicates_are_dead() const;
1259+
Unique_Node_List collect_loop_nodes_of_useless_template_assertion_predicates() const;
1260+
void verify_associated_loop_nodes_are_dead(const Unique_Node_List& loop_nodes_of_useless_template_assertion_predicates) const;
1261+
#endif // ASSERT
12571262
public:
12581263
EliminateUselessPredicates(PhaseIterGVN& igvn, IdealLoopTree* ltree_root)
12591264
: C(igvn.C), _parse_predicates(igvn.C->parse_predicates()),

0 commit comments

Comments
 (0)