From f89381fed12faf96c45a83a989ae2fff82c05f3b Mon Sep 17 00:00:00 2001 From: Anton Shamin Date: Mon, 16 May 2016 16:44:13 +0600 Subject: ART: ArrayGet hoisting restriction added. Currently if we hoist ArrayGet from loop there is no guarantee that insn will be executed at runtime. Because of that we could face issues like crashes in generated code. This patch introduces restriction for ArrayGet hoisting. We say that ArrayGet execution is guaranteed at least one time if its bb dominates all exit blocks. Change-Id: I9f72c0f4c33b358341109238bea46cb5a82f490f Signed-off-by: Anton Shamin --- compiler/optimizing/nodes.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compiler/optimizing/nodes.cc') diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 60329ccff2..f4d3842ff9 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -734,6 +734,15 @@ bool HLoopInformation::HasBackEdgeNotDominatedByHeader() const { return false; } +bool HLoopInformation::DominatesAllBackEdges(HBasicBlock* block) { + for (HBasicBlock* back_edge : GetBackEdges()) { + if (!block->Dominates(back_edge)) { + return false; + } + } + return true; +} + bool HBasicBlock::Dominates(HBasicBlock* other) const { // Walk up the dominator tree from `other`, to find out if `this` // is an ancestor. -- cgit v1.2.3-59-g8ed1b