2007-03-11 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sun, 11 Mar 2007 16:05:44 +0000 (16:05 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sun, 11 Mar 2007 16:05:44 +0000 (16:05 -0000)
* mini.c (mono_method_to_ir): Fix box+brtrue optimization. Fixes
#81102.

* generics.2.cs: Add regression test.

svn path=/trunk/mono/; revision=74069

mono/mini/ChangeLog
mono/mini/generics.2.cs
mono/mini/mini.c

index 1a0ecd0ac08e78ecc5d47c31cb653acb6e461f1c..250fce778f76d153950f705ba6e0a3ef3cc01564 100644 (file)
@@ -1,3 +1,10 @@
+2007-03-11  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini.c (mono_method_to_ir): Fix box+brtrue optimization. Fixes
+       #81102.
+
+       * generics.2.cs: Add regression test.
+
 2007-03-09  Wade berrier  <wberrier@novell.com>
 
        * mini-ppc.h: Undo typo of MONO_CONTEXT_SET_SP (ppc doesn't define this symbol)
index 57ebdfdd9b4f9205598eb6399b08a49d965a7002..f923a6e56c05e93bf55d7381825d35da7f23a104 100644 (file)
@@ -156,6 +156,32 @@ class Tests {
                        return 0;
     }
 
+       public static int test_0_box_brtrue_opt_regress_81102 () {
+               if (new Foo<int>(5).ToString () == "null")
+                       return 0;
+               else
+                       return 1;
+       }
+
+       public class Foo<T1>
+       {
+               public Foo(T1 t1)
+               {
+                       m_t1 = t1;
+               }
+               
+               public override string ToString()
+               {
+                       return Bar(m_t1 == null ? "null" : "null");
+               }
+
+               public String Bar (String s) {
+                       return s;
+               }
+               
+               readonly T1 m_t1;
+       }
+
        public interface IMyHandler {
                object Bar<T>();
        }
index ddc54cd9a44704394f8eb150800fc9846178740d..da202aefb6b6d88fa9c3b28527ff9f4fb994b411 100644 (file)
@@ -6449,6 +6449,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                link_bblock (cfg, bblock, tblock);
                                CHECK_BBLOCK (target, ip, tblock);
                                ins->inst_target_bb = tblock;
+                               GET_BBLOCK (cfg, bbhash, tblock, ip);
+                               link_bblock (cfg, bblock, tblock);
                                if (sp != stack_start) {
                                        handle_stack_args (cfg, bblock, stack_start, sp - stack_start);
                                        sp = stack_start;