diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-05-20 10:23:11 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-05-20 10:23:11 -0700 |
commit | 881f94c087e4417c874dc136d01c31011c24684f (patch) | |
tree | a00fd8e78da47ea21fe289dbc294ca61e010cfb1 /src/relooper/test.cpp | |
parent | 1c8f88f0f870716be6ec0ce76770dc007621016f (diff) |
do not optimize out breaks if it causes excessive nesting
Diffstat (limited to 'src/relooper/test.cpp')
-rw-r--r-- | src/relooper/test.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/relooper/test.cpp b/src/relooper/test.cpp index 9f3ddceb..f319757b 100644 --- a/src/relooper/test.cpp +++ b/src/relooper/test.cpp @@ -1,4 +1,6 @@ +#include <vector> + #include "Relooper.h" int main() { @@ -435,5 +437,34 @@ int main() { puts(r.GetOutputBuffer()); } + + if (1) { + Relooper::MakeOutputBuffer(10); + + printf("\n\n-- lots of exits to an unwind block, possible nesting --\n\n"); + + const int DEPTH = 40; + + std::vector<Block*> blocks; + for (int i = 0; i < DEPTH; i++) blocks.push_back(new Block("// block\n", NULL)); + Block *last = new Block("// last\nreturn;\n", NULL); + Block *UW = new Block("// UW\nresumeException();\n\n", NULL); + + for (int i = 0; i < DEPTH; i++) { + Block *b = blocks[i]; + b->AddBranchTo(i+1 < DEPTH ? blocks[i+1] : last, "check()", NULL); + b->AddBranchTo(UW, NULL, NULL); + } + + Relooper r; + for (int i = 0; i < DEPTH; i++) r.AddBlock(blocks[i]); + r.AddBlock(last); + r.AddBlock(UW); + + r.Calculate(blocks[0]); + r.Render(); + + puts(r.GetOutputBuffer()); + } } |