summaryrefslogtreecommitdiff
path: root/compiler/optimizing/graph_checker.cc
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2015-09-18 10:58:32 +0100
committer David Brazdil <dbrazdil@google.com> 2015-09-18 14:14:53 +0100
commit3eaa32f72b6abd807964134aad4c158946dc92e3 (patch)
tree003aa2bcd15499c7ebfdc5528b607e23f4f452f0 /compiler/optimizing/graph_checker.cc
parent9632d5a5ed8295d63fc82fe418a3b776de4e4459 (diff)
ART: Delete catch phis for undefined vregs.
SSA builder assumed that (eagerly created) catch phis for undefined vregs must be dead and will be deleted by dead phi elimination. This, however, does not hold for --debuggable because the catch phis might be revived for their environment uses. This patch modifies the builder to delete the phis itself. Bug: 24054676 Change-Id: Iaa5f2487ff1c38353b44cb89c709bbff1ecd73cc
Diffstat (limited to 'compiler/optimizing/graph_checker.cc')
-rw-r--r--compiler/optimizing/graph_checker.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc
index af8aa23de5..583da30438 100644
--- a/compiler/optimizing/graph_checker.cc
+++ b/compiler/optimizing/graph_checker.cc
@@ -624,8 +624,31 @@ void SSAChecker::VisitPhi(HPhi* phi) {
}
if (phi->IsCatchPhi()) {
- // The number of inputs of a catch phi corresponds to the total number of
- // throwing instructions caught by this catch block.
+ // The number of inputs of a catch phi should be the total number of throwing
+ // instructions caught by this catch block. We do not enforce this, however,
+ // because we do not remove the corresponding inputs when we prove that an
+ // instruction cannot throw. Instead, we at least test that all phis have the
+ // same, non-zero number of inputs (b/24054676).
+ size_t input_count_this = phi->InputCount();
+ if (input_count_this == 0u) {
+ AddError(StringPrintf("Phi %d in catch block %d has zero inputs.",
+ phi->GetId(),
+ phi->GetBlock()->GetBlockId()));
+ } else {
+ HInstruction* next_phi = phi->GetNext();
+ if (next_phi != nullptr) {
+ size_t input_count_next = next_phi->InputCount();
+ if (input_count_this != input_count_next) {
+ AddError(StringPrintf("Phi %d in catch block %d has %zu inputs, "
+ "but phi %d has %zu inputs.",
+ phi->GetId(),
+ phi->GetBlock()->GetBlockId(),
+ input_count_this,
+ next_phi->GetId(),
+ input_count_next));
+ }
+ }
+ }
} else {
// Ensure the number of inputs of a non-catch phi is the same as the number
// of its predecessors.