From dc330f3d57eb21109243f16df6ba7001a68bb963 Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Wed, 10 Dec 2008 13:09:08 +0000 Subject: In tests: 2008-12-08 Rodrigo Kumpera * bug457574.il: New regression test. * Makefile.am: Test added. Backported from trunk r121174. In mini: 2008-12-10 Rodrigo Kumpera * ssa.c (fold_ins): branch opt can kill dummy switch ops so we can't expect that an OP_BR_REG will be there. * branch-opts.c (remove_block_if_useless): Use MONO_IS_BRANCH_OP instead of checking for the many branch ops. The original check miss OP_BR_REG. Fixes #457574. Backported from trunk r121173 and r121175 svn path=/branches/mono-2-2/mono/; revision=121210 --- mono/mini/ChangeLog | 12 +++++++ mono/mini/branch-opts.c | 8 ++--- mono/mini/ssa2.c | 5 +-- mono/tests/ChangeLog | 8 +++++ mono/tests/Makefile.am | 3 +- mono/tests/bug457574.il | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 123 insertions(+), 9 deletions(-) create mode 100644 mono/tests/bug457574.il diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog index 791a7d3333f..9fcf0efc543 100644 --- a/mono/mini/ChangeLog +++ b/mono/mini/ChangeLog @@ -1,3 +1,15 @@ +2008-12-10 Rodrigo Kumpera + + * ssa.c (fold_ins): branch opt can kill dummy switch ops so we can't + expect that an OP_BR_REG will be there. + + * branch-opts.c (remove_block_if_useless): Use MONO_IS_BRANCH_OP instead of checking + for the many branch ops. The original check miss OP_BR_REG. + + Fixes #457574. + + Backported from trunk r121173 and r121175 + 2008-12-09 Zoltan Varga Backport of r121150. diff --git a/mono/mini/branch-opts.c b/mono/mini/branch-opts.c index 80c45c505f6..ea848d9a050 100644 --- a/mono/mini/branch-opts.c +++ b/mono/mini/branch-opts.c @@ -898,9 +898,7 @@ remove_block_if_useless (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *p if ((previous_bb != cfg->bb_entry) && (previous_bb->region == bb->region) && ((previous_bb->last_ins == NULL) || - ((previous_bb->last_ins->opcode != OP_BR) && - (! (MONO_IS_COND_BRANCH_OP (previous_bb->last_ins))) && - (previous_bb->last_ins->opcode != OP_SWITCH)))) { + (!MONO_IS_BRANCH_OP (previous_bb->last_ins)))) { for (i = 0; i < previous_bb->out_count; i++) { if (previous_bb->out_bb [i] == target_bb) { MonoInst *jump; @@ -1077,9 +1075,7 @@ mono_remove_critical_edges (MonoCompile *cfg) /* If previous_bb "followed through" to bb, */ /* keep it linked with a OP_BR */ if ((previous_bb->last_ins == NULL) || - ((previous_bb->last_ins->opcode != OP_BR) && - (! (MONO_IS_COND_BRANCH_OP (previous_bb->last_ins))) && - (previous_bb->last_ins->opcode != OP_SWITCH))) { + !MONO_IS_BRANCH_OP (previous_bb->last_ins)) { int i; /* Make sure previous_bb really falls through bb */ for (i = 0; i < previous_bb->out_count; i++) { diff --git a/mono/mini/ssa2.c b/mono/mini/ssa2.c index 224546ef8c3..f2b262c0232 100644 --- a/mono/mini/ssa2.c +++ b/mono/mini/ssa2.c @@ -1127,12 +1127,13 @@ fold_ins (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, MonoInst **carray NULLIFY_INS (ins); NULLIFY_INS (ins->next); NULLIFY_INS (ins->next->next); - NULLIFY_INS (ins->next->next->next); + if (ins->next->next->next) + NULLIFY_INS (ins->next->next->next); return; } - if (ins->next->next->next->opcode != OP_BR_REG) { + if (!ins->next->next->next || ins->next->next->next->opcode != OP_BR_REG) { /* A one-way switch which got optimized away */ if (G_UNLIKELY (cfg->verbose_level > 1)) { printf ("\tNo cfold on "); diff --git a/mono/tests/ChangeLog b/mono/tests/ChangeLog index 9fd6a309fa7..a8164070316 100644 --- a/mono/tests/ChangeLog +++ b/mono/tests/ChangeLog @@ -1,3 +1,11 @@ +2008-12-08 Rodrigo Kumpera + + * bug457574.il: New regression test. + + * Makefile.am: Test added. + + Backported from trunk r121174. + 2008-12-03 Mark Probst Backport of r120589. diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am index 662b5934014..b45b30ea8ee 100644 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@ -413,7 +413,8 @@ TEST_IL_SRC= \ generic-valuetype-newobj2.2.il \ generic-valuetype-newobj.2.il \ generic-constrained.2.il \ - bug-81466.il + bug-81466.il \ + bug457574.il # bug-318677.il diff --git a/mono/tests/bug457574.il b/mono/tests/bug457574.il new file mode 100644 index 00000000000..f0dce321153 --- /dev/null +++ b/mono/tests/bug457574.il @@ -0,0 +1,96 @@ +.assembly extern mscorlib +{ +.ver 2:0:0:0 +.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) +} + +.assembly 'bug457574' +{ + +.hash algorithm 0x00008004 +.ver 0:0:0:0 +} +.module repro.exe + + +.class public auto ansi beforefieldinit bug457574_regression extends [mscorlib]System.Object +{ + + .method public static hidebysig default bool test_01 () cil managed + { + .maxstack 6 + .locals init (unsigned int32 V_0, unsigned int32 V_1) + + ldc.i4.0 + stloc.0 + + ldloc.0 + switch (IL_0021, IL_0069) + br IL_0075 + +IL_0021: + br IL_0069 + +IL_0026: + ldloc.0 + ldloc.1 + ceq + brfalse IL_0051 + + br IL_0075 + +IL_0051: + ldloc.1 + stloc.0 + br IL_0077 + +IL_0069: + br IL_0026 + + ldc.i4.1 + stloc.1 + +IL_0075: + ldc.i4.0 + ret + +IL_0077: + ldc.i4.1 + ret + } + + .method public static hidebysig default void test_02 () cil managed + { + + .maxstack 8 + .locals init (int32 V_0) + + ldloc.0 + switch(label_1, label_2) + br end + label_1: + br label_2 + label_3: + nop + nop + br end + label_2: + br label_3 + nop + nop + end: + ret + } + +.method public static hidebysig default void Main () cil managed +{ + .entrypoint + .maxstack 8 + + call bool bug457574_regression::test_01 () + pop + call void bug457574_regression::test_02 () + ret +} + +} -- cgit v1.2.3