summaryrefslogtreecommitdiff
path: root/compiler/optimizing/graph_checker.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2015-06-29 10:56:34 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2015-06-29 10:59:19 +0100
commit30eb58c548bee08468f68eb140a74a51dd7d9b43 (patch)
tree28412484547b9bfb4a4773df103cef5f485c3a67 /compiler/optimizing/graph_checker.cc
parent8d1a8c00b89775a251ac5e26a557f81ac1491a44 (diff)
Do not update the type of something we already know.
This is both an optimization to avoid unneeded nodes, and correctness to avoid replacing the second input of `HInstanceOf` and `HCheckCast` to something that is not `HLoadClass`. bug:22116987 Change-Id: I4907197a9002883d7cae8265a9642512b6201396
Diffstat (limited to 'compiler/optimizing/graph_checker.cc')
-rw-r--r--compiler/optimizing/graph_checker.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc
index d7e6bd8161..9679d0ab70 100644
--- a/compiler/optimizing/graph_checker.cc
+++ b/compiler/optimizing/graph_checker.cc
@@ -257,6 +257,7 @@ void GraphChecker::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) {
}
void GraphChecker::VisitReturn(HReturn* ret) {
+ VisitInstruction(ret);
if (!ret->GetBlock()->GetSingleSuccessor()->IsExitBlock()) {
AddError(StringPrintf("%s:%d does not jump to the exit block.",
ret->DebugName(),
@@ -265,6 +266,7 @@ void GraphChecker::VisitReturn(HReturn* ret) {
}
void GraphChecker::VisitReturnVoid(HReturnVoid* ret) {
+ VisitInstruction(ret);
if (!ret->GetBlock()->GetSingleSuccessor()->IsExitBlock()) {
AddError(StringPrintf("%s:%d does not jump to the exit block.",
ret->DebugName(),
@@ -272,6 +274,30 @@ void GraphChecker::VisitReturnVoid(HReturnVoid* ret) {
}
}
+void GraphChecker::VisitCheckCast(HCheckCast* check) {
+ VisitInstruction(check);
+ HInstruction* input = check->InputAt(1);
+ if (!input->IsLoadClass()) {
+ AddError(StringPrintf("%s:%d expects a HLoadClass as second input, not %s:%d.",
+ check->DebugName(),
+ check->GetId(),
+ input->DebugName(),
+ input->GetId()));
+ }
+}
+
+void GraphChecker::VisitInstanceOf(HInstanceOf* instruction) {
+ VisitInstruction(instruction);
+ HInstruction* input = instruction->InputAt(1);
+ if (!input->IsLoadClass()) {
+ AddError(StringPrintf("%s:%d expects a HLoadClass as second input, not %s:%d.",
+ instruction->DebugName(),
+ instruction->GetId(),
+ input->DebugName(),
+ input->GetId()));
+ }
+}
+
void SSAChecker::VisitBasicBlock(HBasicBlock* block) {
super_type::VisitBasicBlock(block);