Fix topological ordering and use it for optimizations.

Use the topological sort order for ClassInitCheckElimination
and NullCheckEliminationAndTypeInference.

Change-Id: I315ca7f300dd11390f48aefebfe988baf91bdcf1
diff --git a/compiler/dex/post_opt_passes.h b/compiler/dex/post_opt_passes.h
index 445c46d..a1b0df4 100644
--- a/compiler/dex/post_opt_passes.h
+++ b/compiler/dex/post_opt_passes.h
@@ -127,6 +127,23 @@
 };
 
 /**
+ * @class TopologicalSortOrders
+ * @brief Compute the topological sort order of the MIR graph
+ */
+class TopologicalSortOrders : public PassME {
+ public:
+  TopologicalSortOrders() : PassME("TopologicalSortOrders") {
+  }
+
+  void Start(PassDataHolder* data) const {
+    DCHECK(data != nullptr);
+    CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit;
+    DCHECK(c_unit != nullptr);
+    c_unit->mir_graph.get()->ComputeTopologicalSortOrder();
+  }
+};
+
+/**
  * @class DefBlockMatrix
  * @brief Calculate the matrix of definition per basic block
  */