harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r601683 - in /harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer: optpass.cpp optpass.h throwopt.cpp
Date Thu, 06 Dec 2007 10:34:50 GMT
Author: varlax
Date: Thu Dec  6 02:34:49 2007
New Revision: 601683

URL: http://svn.apache.org/viewvc?rev=601683&view=rev
Log:
Applied HARMONY-4784 [drlvm][jit][opt] Loop peeling segfaults on smoke perf/ThrowMany

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/throwopt.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.cpp?rev=601683&r1=601682&r2=601683&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.cpp Thu Dec  6 02:34:49
2007
@@ -31,6 +31,7 @@
 #include "optimizer.h"
 #include "FlowGraph.h"
 #include "StaticProfiler.h"
+#include "deadcodeeliminator.h"
 
 #ifdef _WIN32
   #define snprintf _snprintf
@@ -107,6 +108,22 @@
     computeDominators(irm);
     computeLoops(irm, normalizeLoops);
     computeDominators(irm);
+}
+
+void
+OptPass::dce(IRManager& irm) {
+    DeadCodeEliminator dce(irm);
+    dce.eliminateDeadCode(false);
+}
+
+void
+OptPass::uce(IRManager& irm, bool fixup_ssa) {
+    DeadCodeEliminator dce(irm);
+    dce.eliminateUnreachableCode();
+
+    if (irm.getInSsa() && fixup_ssa) {
+        OptPass::fixupSsa(irm);
+    }    
 }
 
 void

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h?rev=601683&r1=601682&r2=601683&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h Thu Dec  6 02:34:49 2007
@@ -61,6 +61,8 @@
     static void computeDominators(IRManager& irm);
     static void computeLoops(IRManager& irm, bool normalize = true);
     static void computeDominatorsAndLoops(IRManager& irm, bool normalizeLoops = true);
+    static void dce(IRManager& irm);
+    static void uce(IRManager& irm, bool fixup_ssa);
     static void fixupSsa(IRManager& irm);
     static void splitCriticalEdges(IRManager& irm);
     static bool isProfileConsistent(IRManager& irm);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/throwopt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/throwopt.cpp?rev=601683&r1=601682&r2=601683&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/throwopt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/throwopt.cpp Thu Dec  6 02:34:49
2007
@@ -57,6 +57,7 @@
     const Nodes& nodes = flowGraph.getNodes();
     StlVector<bool> visited_nodes(irManager.getMemoryManager(), flowGraph.getMaxNodeId(),
false);
     StlVector<Inst *> pseudo_insts(irManager.getMemoryManager(), 10);
+    StlVector<Edge *> exception_edges(irManager.getMemoryManager());
     LoopTree * loop_tree = irManager.getLoopTree();    
     bool restore_ssa = false;
 
@@ -149,6 +150,10 @@
             // Add direct jump.
             flowGraph.addEdge(throw_node, target_node);
 
+            // Remember exception edge here to remove them all at once at the end.
+            // Removing exception edge right now will generate unreachable code.
+            exception_edges.push_back(throw_node->getExceptionEdge());
+
             // Add pseudo instructions from exeption path.            
             if (pseudo_insts.size() > 0) {
                 Node * pseudo_node = flowGraph.spliceBlockOnEdge(
@@ -206,6 +211,16 @@
     }
 
     if (restore_ssa) {
+        // Remove all remembered exception edges.
+        for (StlVector<Edge *>::iterator it = exception_edges.begin(); it != exception_edges.end();
it++) {
+            flowGraph.removeEdge(*it);
+        }
+
+        // Clean up dead code.
+        OptPass::dce(irManager);
+        OptPass::uce(irManager, false);
+
+        // Restrore SSA form.
         OptPass::computeDominators(irManager);
         DominatorTree* dominatorTree = irManager.getDominatorTree();
         
@@ -213,8 +228,9 @@
         SSABuilder ssaBuilder(opndManager, instFactory, frontier, &flowGraph, irManager.getOptimizerFlags());
         bool phiInserted = ssaBuilder.fixupVars(&flowGraph, irManager.getMethodDesc());
         irManager.setInSsa(true);
-        if (phiInserted)
+        if (phiInserted) {
             irManager.setSsaUpdated();
+        }
     }
 }
 



Mime
View raw message