aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-05-31 13:53:46 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-05-31 13:53:46 -0700
commit77fd3e6d5b83b9147b68393e0bc75a17f4d63d58 (patch)
treefca64506b9dcf94771bafdadc8827a3d24454302
parent2ace38d4b6b3f6e5eb4d7754119c3b38efdc3559 (diff)
add testcase for annoying relooper pattern that generates many control flow overheads
-rw-r--r--src/relooper/test.cpp40
-rw-r--r--src/relooper/test.txt25
2 files changed, 65 insertions, 0 deletions
diff --git a/src/relooper/test.cpp b/src/relooper/test.cpp
index 4275941b..d1db54be 100644
--- a/src/relooper/test.cpp
+++ b/src/relooper/test.cpp
@@ -190,5 +190,45 @@ int main() {
puts(buffer);
}
+
+ if (1) {
+ Relooper::SetOutputBuffer(buffer, sizeof(buffer));
+
+ printf("\n\n-- if (expensive || expensive2) X else Y; Z --\n\n");
+
+ Block *b_a = new Block("// block A\n");
+ Block *b_b = new Block("// block B\n");
+ Block *b_c = new Block("// block C;\n");
+ Block *b_d = new Block("// block D\n");
+ Block *b_e = new Block("// block E\n");
+ Block *b_f = new Block("// block F\n");
+
+ b_a->AddBranchTo(b_c, "expensive()");
+ b_a->AddBranchTo(b_b, NULL);
+
+ b_b->AddBranchTo(b_c, "expensive2()");
+ b_b->AddBranchTo(b_d, NULL);
+
+ b_c->AddBranchTo(b_e, NULL);
+
+ b_d->AddBranchTo(b_e, NULL);
+
+ b_e->AddBranchTo(b_f, NULL);
+
+ b_f->AddBranchTo(b_e, NULL);
+
+ Relooper r;
+ r.AddBlock(b_a);
+ r.AddBlock(b_b);
+ r.AddBlock(b_c);
+ r.AddBlock(b_d);
+ r.AddBlock(b_e);
+
+ r.Calculate(b_a);
+ printf("\n\n");
+ r.Render();
+
+ puts(buffer);
+ }
}
diff --git a/src/relooper/test.txt b/src/relooper/test.txt
index 12d0ef39..c6a895ff 100644
--- a/src/relooper/test.txt
+++ b/src/relooper/test.txt
@@ -109,3 +109,28 @@ while(1) {
// block D
}
+
+
+-- if (expensive || expensive2) X else Y; Z --
+
+
+
+// block A
+do {
+ if (expensive()) {
+ label = 33;
+ } else {
+ // block B
+ if (expensive2()) {
+ label = 33;
+ break;
+ }
+ // block D
+ break;
+ }
+} while(0);
+if (label == 33) {
+ // block C;
+}
+// block E
+