summaryrefslogtreecommitdiffstats
path: root/compiler
diff options
context:
space:
mode:
authorDavid Brazdil <dbrazdil@google.com>2015-02-02 18:58:27 +0000
committerDavid Brazdil <dbrazdil@google.com>2015-02-02 19:02:47 +0000
commit2fd6aa5cb76f0c71cbdcd1189c76e68bf84e8308 (patch)
tree79bc01ffc77cec97eb4b785b8bde9aeb59ab24c7 /compiler
parent852eaffe8e478186e134d88a02843a469118ef8c (diff)
downloadart-2fd6aa5cb76f0c71cbdcd1189c76e68bf84e8308.zip
art-2fd6aa5cb76f0c71cbdcd1189c76e68bf84e8308.tar.gz
art-2fd6aa5cb76f0c71cbdcd1189c76e68bf84e8308.tar.bz2
Fix broken gtests after SuspendCheck optimization
Fixes hardcoded graph dumps in pretty printer tests and an assumption that non-zero branch offset in dex implies presence of HInstructions. Change-Id: Iee273c06b7b36410b4621107bef2f3592ece2f5b
Diffstat (limited to 'compiler')
-rw-r--r--compiler/optimizing/builder.cc9
-rw-r--r--compiler/optimizing/pretty_printer_test.cc18
2 files changed, 12 insertions, 15 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index eed5614..c509606 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -1077,11 +1077,10 @@ void HGraphBuilder::PotentiallyAddSuspendCheck(HBasicBlock* target, uint32_t dex
if (target_offset <= 0) {
// DX generates back edges to the first encountered return. We can save
// time of later passes by not adding redundant suspend checks.
- if (target_offset != 0) {
- DCHECK(target->GetLastInstruction() != nullptr);
- if (target->GetLastInstruction()->IsReturn()) {
- return;
- }
+ HInstruction* last_in_target = target->GetLastInstruction();
+ if (last_in_target != nullptr &&
+ (last_in_target->IsReturn() || last_in_target->IsReturnVoid())) {
+ return;
}
// Add a suspend check to backward branches which may potentially loop. We
diff --git a/compiler/optimizing/pretty_printer_test.cc b/compiler/optimizing/pretty_printer_test.cc
index da6b294..a231a72 100644
--- a/compiler/optimizing/pretty_printer_test.cc
+++ b/compiler/optimizing/pretty_printer_test.cc
@@ -100,17 +100,16 @@ TEST(PrettyPrinterTest, CFG2) {
TEST(PrettyPrinterTest, CFG3) {
const char* expected =
"BasicBlock 0, succ: 1\n"
- " 5: SuspendCheck\n"
- " 6: Goto 1\n"
+ " 4: SuspendCheck\n"
+ " 5: Goto 1\n"
"BasicBlock 1, pred: 0, succ: 3\n"
" 0: Goto 3\n"
"BasicBlock 2, pred: 3, succ: 4\n"
" 1: ReturnVoid\n"
"BasicBlock 3, pred: 1, succ: 2\n"
- " 2: SuspendCheck\n"
- " 3: Goto 2\n"
+ " 2: Goto 2\n"
"BasicBlock 4, pred: 2\n"
- " 4: Exit\n";
+ " 3: Exit\n";
const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x200,
@@ -160,15 +159,14 @@ TEST(PrettyPrinterTest, CFG4) {
TEST(PrettyPrinterTest, CFG5) {
const char* expected =
"BasicBlock 0, succ: 1\n"
- " 4: SuspendCheck\n"
- " 5: Goto 1\n"
+ " 3: SuspendCheck\n"
+ " 4: Goto 1\n"
"BasicBlock 1, pred: 0, 2, succ: 3\n"
" 0: ReturnVoid\n"
"BasicBlock 2, succ: 1\n"
- " 1: SuspendCheck\n"
- " 2: Goto 1\n"
+ " 1: Goto 1\n"
"BasicBlock 3, pred: 1\n"
- " 3: Exit\n";
+ " 2: Exit\n";
const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
Instruction::RETURN_VOID,