20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/shared/barrierSet.hpp"
27 #include "gc/shared/c2/barrierSetC2.hpp"
28 #include "libadt/vectset.hpp"
29 #include "memory/allocation.inline.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "opto/castnode.hpp"
32 #include "opto/cfgnode.hpp"
33 #include "opto/connode.hpp"
34 #include "opto/loopnode.hpp"
35 #include "opto/machnode.hpp"
36 #include "opto/matcher.hpp"
37 #include "opto/node.hpp"
38 #include "opto/opcodes.hpp"
39 #include "opto/regmask.hpp"
40 #include "opto/type.hpp"
41 #include "utilities/copy.hpp"
42 #include "utilities/macros.hpp"
43
44 class RegMask;
45 // #include "phase.hpp"
46 class PhaseTransform;
47 class PhaseGVN;
48
49 // Arena we are currently building Nodes in
50 const uint Node::NotAMachineReg = 0xffff0000;
51
52 #ifndef PRODUCT
53 extern int nodes_created;
54 #endif
55 #ifdef __clang__
56 #pragma clang diagnostic push
57 #pragma GCC diagnostic ignored "-Wuninitialized"
58 #endif
59
1293
1294 //------------------------------remove_dead_region-----------------------------
1295 // This control node is dead. Follow the subgraph below it making everything
1296 // using it dead as well. This will happen normally via the usual IterGVN
1297 // worklist but this call is more efficient. Do not update use-def info
1298 // inside the dead region, just at the borders.
1299 static void kill_dead_code( Node *dead, PhaseIterGVN *igvn ) {
1300 // Con's are a popular node to re-hit in the hash table again.
1301 if( dead->is_Con() ) return;
1302
1303 // Can't put ResourceMark here since igvn->_worklist uses the same arena
1304 // for verify pass with +VerifyOpto and we add/remove elements in it here.
1305 Node_List nstack(Thread::current()->resource_area());
1306
1307 Node *top = igvn->C->top();
1308 nstack.push(dead);
1309 bool has_irreducible_loop = igvn->C->has_irreducible_loop();
1310
1311 while (nstack.size() > 0) {
1312 dead = nstack.pop();
1313 if (dead->outcnt() > 0) {
1314 // Keep dead node on stack until all uses are processed.
1315 nstack.push(dead);
1316 // For all Users of the Dead... ;-)
1317 for (DUIterator_Last kmin, k = dead->last_outs(kmin); k >= kmin; ) {
1318 Node* use = dead->last_out(k);
1319 igvn->hash_delete(use); // Yank from hash table prior to mod
1320 if (use->in(0) == dead) { // Found another dead node
1321 assert (!use->is_Con(), "Control for Con node should be Root node.");
1322 use->set_req(0, top); // Cut dead edge to prevent processing
1323 nstack.push(use); // the dead node again.
1324 } else if (!has_irreducible_loop && // Backedge could be alive in irreducible loop
1325 use->is_Loop() && !use->is_Root() && // Don't kill Root (RootNode extends LoopNode)
1326 use->in(LoopNode::EntryControl) == dead) { // Dead loop if its entry is dead
1327 use->set_req(LoopNode::EntryControl, top); // Cut dead edge to prevent processing
1328 use->set_req(0, top); // Cut self edge
1329 nstack.push(use);
1330 } else { // Else found a not-dead user
1331 // Dead if all inputs are top or null
1332 bool dead_use = !use->is_Root(); // Keep empty graph alive
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/shared/barrierSet.hpp"
27 #include "gc/shared/c2/barrierSetC2.hpp"
28 #include "libadt/vectset.hpp"
29 #include "memory/allocation.inline.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "opto/castnode.hpp"
32 #include "opto/cfgnode.hpp"
33 #include "opto/connode.hpp"
34 #include "opto/loopnode.hpp"
35 #include "opto/machnode.hpp"
36 #include "opto/matcher.hpp"
37 #include "opto/node.hpp"
38 #include "opto/opcodes.hpp"
39 #include "opto/regmask.hpp"
40 #include "opto/rootnode.hpp"
41 #include "opto/type.hpp"
42 #include "utilities/copy.hpp"
43 #include "utilities/macros.hpp"
44
45 class RegMask;
46 // #include "phase.hpp"
47 class PhaseTransform;
48 class PhaseGVN;
49
50 // Arena we are currently building Nodes in
51 const uint Node::NotAMachineReg = 0xffff0000;
52
53 #ifndef PRODUCT
54 extern int nodes_created;
55 #endif
56 #ifdef __clang__
57 #pragma clang diagnostic push
58 #pragma GCC diagnostic ignored "-Wuninitialized"
59 #endif
60
1294
1295 //------------------------------remove_dead_region-----------------------------
1296 // This control node is dead. Follow the subgraph below it making everything
1297 // using it dead as well. This will happen normally via the usual IterGVN
1298 // worklist but this call is more efficient. Do not update use-def info
1299 // inside the dead region, just at the borders.
1300 static void kill_dead_code( Node *dead, PhaseIterGVN *igvn ) {
1301 // Con's are a popular node to re-hit in the hash table again.
1302 if( dead->is_Con() ) return;
1303
1304 // Can't put ResourceMark here since igvn->_worklist uses the same arena
1305 // for verify pass with +VerifyOpto and we add/remove elements in it here.
1306 Node_List nstack(Thread::current()->resource_area());
1307
1308 Node *top = igvn->C->top();
1309 nstack.push(dead);
1310 bool has_irreducible_loop = igvn->C->has_irreducible_loop();
1311
1312 while (nstack.size() > 0) {
1313 dead = nstack.pop();
1314 if (dead->Opcode() == Op_SafePoint) {
1315 dead->as_SafePoint()->disconnect_from_root(igvn);
1316 }
1317 if (dead->outcnt() > 0) {
1318 // Keep dead node on stack until all uses are processed.
1319 nstack.push(dead);
1320 // For all Users of the Dead... ;-)
1321 for (DUIterator_Last kmin, k = dead->last_outs(kmin); k >= kmin; ) {
1322 Node* use = dead->last_out(k);
1323 igvn->hash_delete(use); // Yank from hash table prior to mod
1324 if (use->in(0) == dead) { // Found another dead node
1325 assert (!use->is_Con(), "Control for Con node should be Root node.");
1326 use->set_req(0, top); // Cut dead edge to prevent processing
1327 nstack.push(use); // the dead node again.
1328 } else if (!has_irreducible_loop && // Backedge could be alive in irreducible loop
1329 use->is_Loop() && !use->is_Root() && // Don't kill Root (RootNode extends LoopNode)
1330 use->in(LoopNode::EntryControl) == dead) { // Dead loop if its entry is dead
1331 use->set_req(LoopNode::EntryControl, top); // Cut dead edge to prevent processing
1332 use->set_req(0, top); // Cut self edge
1333 nstack.push(use);
1334 } else { // Else found a not-dead user
1335 // Dead if all inputs are top or null
1336 bool dead_use = !use->is_Root(); // Keep empty graph alive
|