From de663f907368a9fadafddd0077a4cedf7451fd42 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 14 Jul 2022 15:36:20 -0400 Subject: [PATCH 1/5] [mono][jit] Fix an infinite loop in the abcrem pass. Fixes https://github.com/dotnet/runtime/issues/71592. --- src/mono/mono/mini/abcremoval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/abcremoval.c b/src/mono/mono/mini/abcremoval.c index 44317cdac6c5cb..c758a485a0fcfa 100644 --- a/src/mono/mono/mini/abcremoval.c +++ b/src/mono/mono/mini/abcremoval.c @@ -493,7 +493,7 @@ get_relations_from_previous_bb (MonoVariableRelationsEvaluationArea *area, MonoB symmetric_relation = MONO_SYMMETRIC_RELATION (branch_relation); /* FIXME: Other compare opcodes */ - if (compare->opcode == OP_ICOMPARE) { + if (compare->opcode == OP_ICOMPARE && compare->sreg1 != compare->sreg2) { relations->relation1.variable = compare->sreg1; relations->relation1.relation.relation = branch_relation; relations->relation1.relation.related_value.type = MONO_VARIABLE_SUMMARIZED_VALUE; From a1b9996c6b5d96923505aaa64d295d5ff7c6b542 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 19 Jul 2022 13:57:44 -0400 Subject: [PATCH 2/5] Add a test. --- .../JitBlue/Runtime_71592/test71592.cs | 30 +++++++++++++++++++ .../JitBlue/Runtime_71592/test71592.csproj | 9 ++++++ 2 files changed, 39 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs new file mode 100644 index 00000000000000..4a814cee7b5a10 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Threading.Tasks; + +public class Test +{ + public int foo; + + public static bool operator ==(Test t1, Test t2) { + if (ReferenceEquals(t1, t1)) + return true; + return t1.foo == t2.foo; + } + + public static bool operator !=(Test t1, Test t2) { + if (ReferenceEquals(t1, t1)) + return true; + return t1.foo == t2.foo; + } + + public static int Main () { + var t1 = new Test () { foo = 1 }; + var t2 = new Test () { foo = 2 }; + if (t1 == t2) + return 0; + return 100; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj new file mode 100644 index 00000000000000..6b742690ec6890 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj @@ -0,0 +1,9 @@ + + + Exe + 1 + + + + + From 21b1b738d92b74b540a1c037538f7df62f947757 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Wed, 20 Jul 2022 14:42:04 +0200 Subject: [PATCH 3/5] Fix pri1 test build --- src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs index 4a814cee7b5a10..45e8e3476e0807 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs +++ b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs @@ -8,6 +8,9 @@ public class Test { public int foo; + public override bool Equals(object o) => false; + public override int GetHashCode() => 0; + public static bool operator ==(Test t1, Test t2) { if (ReferenceEquals(t1, t1)) return true; From 64a40f2dd38aa6cdd4ccca6b62ed304387e3a910 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 21 Jul 2022 02:39:12 -0400 Subject: [PATCH 4/5] Fix the test. --- src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs index 45e8e3476e0807..21912e06ce8810 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs +++ b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs @@ -27,7 +27,7 @@ public static int Main () { var t1 = new Test () { foo = 1 }; var t2 = new Test () { foo = 2 }; if (t1 == t2) - return 0; + return 100; return 100; } } From 3a5ab67dede9f68822309550a73e5a352a76aba8 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 21 Jul 2022 12:08:09 -0400 Subject: [PATCH 5/5] Update src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aleksey Kliger (λgeek) --- src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj index 6b742690ec6890..4ccbe30ff30925 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj +++ b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj @@ -1,7 +1,7 @@ Exe - 1 + 0