Commit fa041c90 authored by weiliang.lin's avatar weiliang.lin Committed by Commit bot

Make RawMachineAssemblerTest emitting CFG always have a dummy End block

Frame Elider requires a sane CFG which should have such dummy end block.

BUG=

Review URL: https://codereview.chromium.org/1166293004

Cr-Commit-Position: refs/heads/master@{#28911}
parent 29c23977
...@@ -23,7 +23,6 @@ RawMachineAssembler::RawMachineAssembler(Isolate* isolate, Graph* graph, ...@@ -23,7 +23,6 @@ RawMachineAssembler::RawMachineAssembler(Isolate* isolate, Graph* graph,
call_descriptor_( call_descriptor_(
Linkage::GetSimplifiedCDescriptor(graph->zone(), machine_sig)), Linkage::GetSimplifiedCDescriptor(graph->zone(), machine_sig)),
parameters_(NULL), parameters_(NULL),
exit_label_(schedule()->end()),
current_block_(schedule()->start()) { current_block_(schedule()->start()) {
int param_count = static_cast<int>(parameter_count()); int param_count = static_cast<int>(parameter_count());
Node* s = graph->NewNode(common_.Start(param_count)); Node* s = graph->NewNode(common_.Start(param_count));
...@@ -54,12 +53,6 @@ Node* RawMachineAssembler::Parameter(size_t index) { ...@@ -54,12 +53,6 @@ Node* RawMachineAssembler::Parameter(size_t index) {
} }
RawMachineAssembler::Label* RawMachineAssembler::Exit() {
exit_label_.used_ = true;
return &exit_label_;
}
void RawMachineAssembler::Goto(Label* label) { void RawMachineAssembler::Goto(Label* label) {
DCHECK(current_block_ != schedule()->end()); DCHECK(current_block_ != schedule()->end());
schedule()->AddGoto(CurrentBlock(), Use(label)); schedule()->AddGoto(CurrentBlock(), Use(label));
......
...@@ -458,7 +458,6 @@ class RawMachineAssembler : public GraphBuilder { ...@@ -458,7 +458,6 @@ class RawMachineAssembler : public GraphBuilder {
} }
// Control flow. // Control flow.
Label* Exit();
void Goto(Label* label); void Goto(Label* label);
void Branch(Node* condition, Label* true_val, Label* false_val); void Branch(Node* condition, Label* true_val, Label* false_val);
void Switch(Node* index, Label* default_label, int32_t* case_values, void Switch(Node* index, Label* default_label, int32_t* case_values,
...@@ -512,7 +511,6 @@ class RawMachineAssembler : public GraphBuilder { ...@@ -512,7 +511,6 @@ class RawMachineAssembler : public GraphBuilder {
const MachineSignature* machine_sig_; const MachineSignature* machine_sig_;
CallDescriptor* call_descriptor_; CallDescriptor* call_descriptor_;
Node** parameters_; Node** parameters_;
Label exit_label_;
BasicBlock* current_block_; BasicBlock* current_block_;
DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler);
......
...@@ -164,15 +164,14 @@ template <typename R> ...@@ -164,15 +164,14 @@ template <typename R>
static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node, static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node,
MachineType type, Node* true_node, MachineType type, Node* true_node,
Node* false_node) { Node* false_node) {
MLabel blocka, blockb; MLabel blocka, blockb, end;
MLabel* end = m->Exit();
m->Branch(cond_node, &blocka, &blockb); m->Branch(cond_node, &blocka, &blockb);
m->Bind(&blocka); m->Bind(&blocka);
m->Goto(end); m->Goto(&end);
m->Bind(&blockb); m->Bind(&blockb);
m->Goto(end); m->Goto(&end);
m->Bind(end); m->Bind(&end);
Node* phi = m->Phi(type, true_node, false_node); Node* phi = m->Phi(type, true_node, false_node);
m->Return(phi); m->Return(phi);
} }
...@@ -237,16 +236,15 @@ TEST(RunLoopPhiConst) { ...@@ -237,16 +236,15 @@ TEST(RunLoopPhiConst) {
Node* false_node = m.Int32Constant(false_val); Node* false_node = m.Int32Constant(false_val);
// x = false_val; while(false) { x = true_val; } return x; // x = false_val; while(false) { x = true_val; } return x;
MLabel body, header; MLabel body, header, end;
MLabel* end = m.Exit();
m.Goto(&header); m.Goto(&header);
m.Bind(&header); m.Bind(&header);
Node* phi = m.Phi(kMachInt32, false_node, true_node); Node* phi = m.Phi(kMachInt32, false_node, true_node);
m.Branch(cond_node, &body, end); m.Branch(cond_node, &body, &end);
m.Bind(&body); m.Bind(&body);
m.Goto(&header); m.Goto(&header);
m.Bind(end); m.Bind(&end);
m.Return(phi); m.Return(phi);
CHECK_EQ(false_val, m.Call()); CHECK_EQ(false_val, m.Call());
...@@ -256,20 +254,19 @@ TEST(RunLoopPhiConst) { ...@@ -256,20 +254,19 @@ TEST(RunLoopPhiConst) {
TEST(RunLoopPhiParam) { TEST(RunLoopPhiParam) {
RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32);
MLabel blocka, blockb; MLabel blocka, blockb, end;
MLabel* end = m.Exit();
m.Goto(&blocka); m.Goto(&blocka);
m.Bind(&blocka); m.Bind(&blocka);
Node* phi = m.Phi(kMachInt32, m.Parameter(1), m.Parameter(2)); Node* phi = m.Phi(kMachInt32, m.Parameter(1), m.Parameter(2));
Node* cond = m.Phi(kMachInt32, m.Parameter(0), m.Int32Constant(0)); Node* cond = m.Phi(kMachInt32, m.Parameter(0), m.Int32Constant(0));
m.Branch(cond, &blockb, end); m.Branch(cond, &blockb, &end);
m.Bind(&blockb); m.Bind(&blockb);
m.Goto(&blocka); m.Goto(&blocka);
m.Bind(end); m.Bind(&end);
m.Return(phi); m.Return(phi);
int32_t c1 = 0xa81903b4; int32_t c1 = 0xa81903b4;
...@@ -287,22 +284,21 @@ TEST(RunLoopPhiInduction) { ...@@ -287,22 +284,21 @@ TEST(RunLoopPhiInduction) {
int false_val = 0x10777; int false_val = 0x10777;
// x = false_val; while(false) { x++; } return x; // x = false_val; while(false) { x++; } return x;
MLabel header, body; MLabel header, body, end;
MLabel* end = m.Exit();
Node* false_node = m.Int32Constant(false_val); Node* false_node = m.Int32Constant(false_val);
m.Goto(&header); m.Goto(&header);
m.Bind(&header); m.Bind(&header);
Node* phi = m.Phi(kMachInt32, false_node, false_node); Node* phi = m.Phi(kMachInt32, false_node, false_node);
m.Branch(m.Int32Constant(0), &body, end); m.Branch(m.Int32Constant(0), &body, &end);
m.Bind(&body); m.Bind(&body);
Node* add = m.Int32Add(phi, m.Int32Constant(1)); Node* add = m.Int32Add(phi, m.Int32Constant(1));
phi->ReplaceInput(1, add); phi->ReplaceInput(1, add);
m.Goto(&header); m.Goto(&header);
m.Bind(end); m.Bind(&end);
m.Return(phi); m.Return(phi);
CHECK_EQ(false_val, m.Call()); CHECK_EQ(false_val, m.Call());
...@@ -314,21 +310,20 @@ TEST(RunLoopIncrement) { ...@@ -314,21 +310,20 @@ TEST(RunLoopIncrement) {
Int32BinopTester bt(&m); Int32BinopTester bt(&m);
// x = 0; while(x ^ param) { x++; } return x; // x = 0; while(x ^ param) { x++; } return x;
MLabel header, body; MLabel header, body, end;
MLabel* end = m.Exit();
Node* zero = m.Int32Constant(0); Node* zero = m.Int32Constant(0);
m.Goto(&header); m.Goto(&header);
m.Bind(&header); m.Bind(&header);
Node* phi = m.Phi(kMachInt32, zero, zero); Node* phi = m.Phi(kMachInt32, zero, zero);
m.Branch(m.WordXor(phi, bt.param0), &body, end); m.Branch(m.WordXor(phi, bt.param0), &body, &end);
m.Bind(&body); m.Bind(&body);
phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1)));
m.Goto(&header); m.Goto(&header);
m.Bind(end); m.Bind(&end);
bt.AddReturn(phi); bt.AddReturn(phi);
CHECK_EQ(11, bt.call(11, 0)); CHECK_EQ(11, bt.call(11, 0));
...@@ -342,21 +337,20 @@ TEST(RunLoopIncrement2) { ...@@ -342,21 +337,20 @@ TEST(RunLoopIncrement2) {
Int32BinopTester bt(&m); Int32BinopTester bt(&m);
// x = 0; while(x < param) { x++; } return x; // x = 0; while(x < param) { x++; } return x;
MLabel header, body; MLabel header, body, end;
MLabel* end = m.Exit();
Node* zero = m.Int32Constant(0); Node* zero = m.Int32Constant(0);
m.Goto(&header); m.Goto(&header);
m.Bind(&header); m.Bind(&header);
Node* phi = m.Phi(kMachInt32, zero, zero); Node* phi = m.Phi(kMachInt32, zero, zero);
m.Branch(m.Int32LessThan(phi, bt.param0), &body, end); m.Branch(m.Int32LessThan(phi, bt.param0), &body, &end);
m.Bind(&body); m.Bind(&body);
phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1)));
m.Goto(&header); m.Goto(&header);
m.Bind(end); m.Bind(&end);
bt.AddReturn(phi); bt.AddReturn(phi);
CHECK_EQ(11, bt.call(11, 0)); CHECK_EQ(11, bt.call(11, 0));
...@@ -371,21 +365,20 @@ TEST(RunLoopIncrement3) { ...@@ -371,21 +365,20 @@ TEST(RunLoopIncrement3) {
Int32BinopTester bt(&m); Int32BinopTester bt(&m);
// x = 0; while(x < param) { x++; } return x; // x = 0; while(x < param) { x++; } return x;
MLabel header, body; MLabel header, body, end;
MLabel* end = m.Exit();
Node* zero = m.Int32Constant(0); Node* zero = m.Int32Constant(0);
m.Goto(&header); m.Goto(&header);
m.Bind(&header); m.Bind(&header);
Node* phi = m.Phi(kMachInt32, zero, zero); Node* phi = m.Phi(kMachInt32, zero, zero);
m.Branch(m.Uint32LessThan(phi, bt.param0), &body, end); m.Branch(m.Uint32LessThan(phi, bt.param0), &body, &end);
m.Bind(&body); m.Bind(&body);
phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1)));
m.Goto(&header); m.Goto(&header);
m.Bind(end); m.Bind(&end);
bt.AddReturn(phi); bt.AddReturn(phi);
CHECK_EQ(11, bt.call(11, 0)); CHECK_EQ(11, bt.call(11, 0));
...@@ -400,20 +393,19 @@ TEST(RunLoopDecrement) { ...@@ -400,20 +393,19 @@ TEST(RunLoopDecrement) {
Int32BinopTester bt(&m); Int32BinopTester bt(&m);
// x = param; while(x) { x--; } return x; // x = param; while(x) { x--; } return x;
MLabel header, body; MLabel header, body, end;
MLabel* end = m.Exit();
m.Goto(&header); m.Goto(&header);
m.Bind(&header); m.Bind(&header);
Node* phi = m.Phi(kMachInt32, bt.param0, m.Int32Constant(0)); Node* phi = m.Phi(kMachInt32, bt.param0, m.Int32Constant(0));
m.Branch(phi, &body, end); m.Branch(phi, &body, &end);
m.Bind(&body); m.Bind(&body);
phi->ReplaceInput(1, m.Int32Sub(phi, m.Int32Constant(1))); phi->ReplaceInput(1, m.Int32Sub(phi, m.Int32Constant(1)));
m.Goto(&header); m.Goto(&header);
m.Bind(end); m.Bind(&end);
bt.AddReturn(phi); bt.AddReturn(phi);
CHECK_EQ(0, bt.call(11, 0)); CHECK_EQ(0, bt.call(11, 0));
...@@ -426,8 +418,7 @@ TEST(RunLoopIncrementFloat32) { ...@@ -426,8 +418,7 @@ TEST(RunLoopIncrementFloat32) {
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
// x = -3.0f; while(x < 10f) { x = x + 0.5f; } return (int) (double) x; // x = -3.0f; while(x < 10f) { x = x + 0.5f; } return (int) (double) x;
MLabel header, body; MLabel header, body, end;
MLabel* end = m.Exit();
Node* minus_3 = m.Float32Constant(-3.0f); Node* minus_3 = m.Float32Constant(-3.0f);
Node* ten = m.Float32Constant(10.0f); Node* ten = m.Float32Constant(10.0f);
...@@ -435,13 +426,13 @@ TEST(RunLoopIncrementFloat32) { ...@@ -435,13 +426,13 @@ TEST(RunLoopIncrementFloat32) {
m.Bind(&header); m.Bind(&header);
Node* phi = m.Phi(kMachFloat32, minus_3, ten); Node* phi = m.Phi(kMachFloat32, minus_3, ten);
m.Branch(m.Float32LessThan(phi, ten), &body, end); m.Branch(m.Float32LessThan(phi, ten), &body, &end);
m.Bind(&body); m.Bind(&body);
phi->ReplaceInput(1, m.Float32Add(phi, m.Float32Constant(0.5f))); phi->ReplaceInput(1, m.Float32Add(phi, m.Float32Constant(0.5f)));
m.Goto(&header); m.Goto(&header);
m.Bind(end); m.Bind(&end);
m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(phi))); m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(phi)));
CHECK_EQ(10, m.Call()); CHECK_EQ(10, m.Call());
...@@ -452,8 +443,7 @@ TEST(RunLoopIncrementFloat64) { ...@@ -452,8 +443,7 @@ TEST(RunLoopIncrementFloat64) {
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
// x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x; // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x;
MLabel header, body; MLabel header, body, end;
MLabel* end = m.Exit();
Node* minus_3 = m.Float64Constant(-3.0); Node* minus_3 = m.Float64Constant(-3.0);
Node* ten = m.Float64Constant(10.0); Node* ten = m.Float64Constant(10.0);
...@@ -461,13 +451,13 @@ TEST(RunLoopIncrementFloat64) { ...@@ -461,13 +451,13 @@ TEST(RunLoopIncrementFloat64) {
m.Bind(&header); m.Bind(&header);
Node* phi = m.Phi(kMachFloat64, minus_3, ten); Node* phi = m.Phi(kMachFloat64, minus_3, ten);
m.Branch(m.Float64LessThan(phi, ten), &body, end); m.Branch(m.Float64LessThan(phi, ten), &body, &end);
m.Bind(&body); m.Bind(&body);
phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5))); phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5)));
m.Goto(&header); m.Goto(&header);
m.Bind(end); m.Bind(&end);
m.Return(m.ChangeFloat64ToInt32(phi)); m.Return(m.ChangeFloat64ToInt32(phi));
CHECK_EQ(10, m.Call()); CHECK_EQ(10, m.Call());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment