]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
avoid jump tables while cleaning branches
authorAleksey Demakov <ademakov@gmail.com>
Mon, 3 Aug 2009 17:30:00 +0000 (00:30 +0700)
committerAleksey Demakov <ademakov@gmail.com>
Mon, 3 Aug 2009 17:30:00 +0000 (00:30 +0700)
ChangeLog
jit/jit-block.c

index 07241906b7570ca7ba280ab2615f8d916f14f317..7f06913a63d6eddb73d2479d54d3c724ffb581ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-08-04  Aleksey Demakov  <ademakov@gmail.com>
+
+       * jit/jit-block.c (_jit_block_clean_cfg): avoid jump tables
+       while cleaning branches (thanks Fredrik Ehnbom).
+
 2009-06-10  Aleksey Demakov  <ademakov@gmail.com>
 
        * jit/jit-rules-x86.ins (JIT_OP_BR_LFALSE): add opcode rule.
index 43e9a67a77444d5aac463ab283d97d39dbe7486a..82e27911de9aef4d6f5d65110381cbb84d2d920e 100644 (file)
@@ -604,11 +604,16 @@ _jit_block_clean_cfg(jit_function_t func)
                }
                if(block->succs[0]->flags == _JIT_EDGE_BRANCH)
                {
+                       insn = _jit_block_get_last(block);
+                       if(insn->opcode == JIT_OP_JUMP_TABLE)
+                       {
+                               /* skip jump tables, handle only branches */
+                               continue;
+                       }
                        if(block->succs[0]->dst == block->next)
                        {
                                /* Replace useless branch with NOP */
                                changed = 1;
-                               insn = _jit_block_get_last(block);
                                insn->opcode = JIT_OP_NOP;
                                if(block->num_succs == 1)
                                {
@@ -633,7 +638,6 @@ _jit_block_clean_cfg(jit_function_t func)
                                   remove the fallthough edge while leaving the branch
                                   edge */
                                changed = 1;
-                               insn = _jit_block_get_last(block);
                                insn->opcode = JIT_OP_BR;
                                block->ends_in_dead = 1;
                                delete_edge(func, block->succs[1]);