Permalink
Browse files

Fix register allocation bug for ternary ops.

2009-03-25  Mark Probst  <mark.probst@gmail.com>

        * mini-codegen.c (mono_local_regalloc): Don't let sregs get
        allocated to the same registers as fixed sregs.

2009-03-25  Mark Probst  <mark.probst@gmail.com>

        * interlocked-4.2.cs: New CompareExchange test (triggered
        * register
        allocation bug on x86 and amd64).

        * Makefile.am: Test added.

svn path=/trunk/mono/; revision=130247
  • Loading branch information...
1 parent 5c5b5fe commit 60a6620327abed327b0e339459aa9e9128c8fb66 @schani schani committed Mar 25, 2009
Showing with 41 additions and 1 deletion.
  1. +5 −0 mono/mini/ChangeLog
  2. +5 −0 mono/mini/mini-codegen.c
  3. +7 −0 mono/tests/ChangeLog
  4. +2 −1 mono/tests/Makefile.am
  5. +22 −0 mono/tests/interlocked-4.2.cs
View
@@ -1,3 +1,8 @@
+2009-03-25 Mark Probst <mark.probst@gmail.com>
+
+ * mini-codegen.c (mono_local_regalloc): Don't let sregs get
+ allocated to the same registers as fixed sregs.
+
2009-03-24 Mark Probst <mark.probst@gmail.com>
* mini-ops.h: New ternary ATOMIC_CAS ops replace the old
View
@@ -1201,9 +1201,14 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
if (dest_sreg != -1) {
if (rs->ifree_mask & (regmask (dest_sreg))) {
if (is_global_ireg (sreg)) {
+ int k;
/* Argument already in hard reg, need to copy */
MonoInst *copy = create_copy_ins (cfg, bb, tmp, dest_sreg, sreg, NULL, ip, 0);
insert_before_ins (bb, ins, copy);
+ for (k = 0; k < num_sregs; ++k) {
+ if (k != j)
+ sreg_masks [k] &= ~ (regmask (dest_sreg));
+ }
}
else {
val = rs->vassign [sreg];
View
@@ -1,3 +1,10 @@
+2009-03-25 Mark Probst <mark.probst@gmail.com>
+
+ * interlocked-4.2.cs: New CompareExchange test (triggered register
+ allocation bug on x86 and amd64).
+
+ * Makefile.am: Test added.
+
2009-03-24 Mark Probst <mark.probst@gmail.com>
* interlocked-3.cs: New CompareExchange test.
View
@@ -348,7 +348,8 @@ BASE_TEST_CS_SRC= \
appdomain-unload-callback.cs \
bug-472692.2.cs \
gchandles.cs \
- interlocked-3.cs
+ interlocked-3.cs \
+ interlocked-4.2.cs
if AMD64
TEST_CS_SRC = $(BASE_TEST_CS_SRC) async-exc-compilation.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Threading;
+public class DifferentialOperator
+{
+ static void Main (string[] args)
+ {
+ WeakReference weakref = null;
+ Swap (ref weakref, new object ());
+ if (weakref == null)
+ throw new Exception ();
+ }
+
+ static void Swap(ref WeakReference refNmsp, object o)
+ {
+ WeakReference wref = refNmsp;
+ if (wref != null)
+ {
+ Console.WriteLine ("Need this to make it pass");
+ }
+ Interlocked.CompareExchange<WeakReference>(ref refNmsp, new WeakReference(o), wref);
+ }
+}

0 comments on commit 60a6620

Please sign in to comment.