Index: src/compiler/scheduler.cc |
diff --git a/src/compiler/scheduler.cc b/src/compiler/scheduler.cc |
index d1da320bd0d48dd23e299a2de1ff52a75f207d96..4b176f56c975dfe60205039e1e76f9305535ec92 100644 |
--- a/src/compiler/scheduler.cc |
+++ b/src/compiler/scheduler.cc |
@@ -239,9 +239,16 @@ class CFGBuilder { |
switch (node->opcode()) { |
case IrOpcode::kLoop: |
case IrOpcode::kMerge: |
- case IrOpcode::kTerminate: |
BuildBlockForNode(node); |
break; |
+ case IrOpcode::kTerminate: { |
+ // Put Terminate in the loop to which it refers. |
+ Node* loop = NodeProperties::GetControlInput(node); |
+ BuildBlockForNode(loop); |
+ BasicBlock* block = schedule_->block(loop); |
Michael Starzinger
2014/10/29 12:14:02
nit: This probably should use the return value of
titzer
2014/10/29 15:17:09
Done. While doing this I noticed a bug and had to
|
+ FixNode(block, node); |
+ break; |
+ } |
case IrOpcode::kBranch: |
BuildBlocksForSuccessors(node, IrOpcode::kIfTrue, IrOpcode::kIfFalse); |
break; |
@@ -269,13 +276,15 @@ class CFGBuilder { |
} |
} |
- void BuildBlockForNode(Node* node) { |
- if (schedule_->block(node) == NULL) { |
- BasicBlock* block = schedule_->NewBasicBlock(); |
+ BasicBlock* BuildBlockForNode(Node* node) { |
+ BasicBlock* block = schedule_->block(node); |
+ if (block == NULL) { |
+ block = schedule_->NewBasicBlock(); |
Trace("Create block B%d for #%d:%s\n", block->id().ToInt(), node->id(), |
node->op()->mnemonic()); |
FixNode(block, node); |
} |
+ return block; |
} |
void BuildBlocksForSuccessors(Node* node, IrOpcode::Value a, |