From 7d72154be60b19c1231a4e43ca2da9afd4c3142b Mon Sep 17 00:00:00 2001 From: Brian Sullivan Date: Wed, 20 Feb 2019 16:26:38 -0800 Subject: [PATCH 1/3] Fix Isuue 22436 - noway_assert 'expTyp == cseLclVarTyp' in optcse.cpp We now allow TYP_BYREF to be compatible with TYP_I_IMPL when performing CSE substitutions. Re-enable the failing BestFitMapping interop tests Commit migrated from https://github.com/dotnet/coreclr/commit/7221f02352e5699b0f4e3ac0c94cab4fa06d7708 --- src/coreclr/src/jit/optcse.cpp | 25 ++++++++++++++++++++++++- src/coreclr/tests/issues.targets | 18 ------------------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/coreclr/src/jit/optcse.cpp b/src/coreclr/src/jit/optcse.cpp index f578b2aa7e3..67cc64e4351 100644 --- a/src/coreclr/src/jit/optcse.cpp +++ b/src/coreclr/src/jit/optcse.cpp @@ -1971,6 +1971,26 @@ public: return result; } + // IsCompatibleType() takes two var_types and returns true if they + // are compatible types for CSE substitution + // + bool IsCompatibleType(var_types cseLclVarTyp, var_types expTyp) + { + // Excat type match is the expected case + if (cseLclVarTyp == expTyp) + return true; + + // We also allow TYP_BYREF and TYP_I_IMPL as compatible types + // + if ((cseLclVarTyp == TYP_BYREF) && (expTyp == TYP_I_IMPL)) + return true; + if ((cseLclVarTyp == TYP_I_IMPL) && (expTyp == TYP_BYREF)) + return true; + + // Otherwise we have incompatible types + return false; + } + // PerformCSE() takes a successful candidate and performs the appropriate replacements: // // It will replace all of the CSE defs with assignments to a new "cse0" LclVar @@ -2105,7 +2125,10 @@ public: /* Figure out the actual type of the value */ var_types expTyp = genActualType(exp->TypeGet()); - noway_assert(expTyp == cseLclVarTyp); + + // The cseLclVarType must be a compatible with expTyp + // + noway_assert(IsCompatibleType(cseLclVarTyp, expTyp)); // This will contain the replacement tree for exp // It will either be the CSE def or CSE ref diff --git a/src/coreclr/tests/issues.targets b/src/coreclr/tests/issues.targets index bfaf3f20e61..ab069b53674 100644 --- a/src/coreclr/tests/issues.targets +++ b/src/coreclr/tests/issues.targets @@ -255,18 +255,6 @@ Varargs supported on this platform - - 22436 - - - 22436 - - - 22436 - - - 22436 - @@ -295,12 +283,6 @@ Varargs supported on this platform - - 22436 - - - 22436 - From 851ea7f82301dd8958991cea6df297e76fa9be35 Mon Sep 17 00:00:00 2001 From: Brian Sullivan Date: Thu, 21 Feb 2019 09:29:07 -0800 Subject: [PATCH 2/3] Added enclosing brances for if/then stmts Commit migrated from https://github.com/dotnet/coreclr/commit/d5541e44fbae473aefe229de81d56fe238b405e8 --- src/coreclr/src/jit/optcse.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/coreclr/src/jit/optcse.cpp b/src/coreclr/src/jit/optcse.cpp index 67cc64e4351..688c2092f0d 100644 --- a/src/coreclr/src/jit/optcse.cpp +++ b/src/coreclr/src/jit/optcse.cpp @@ -1978,14 +1978,20 @@ public: { // Excat type match is the expected case if (cseLclVarTyp == expTyp) + { return true; + } // We also allow TYP_BYREF and TYP_I_IMPL as compatible types // if ((cseLclVarTyp == TYP_BYREF) && (expTyp == TYP_I_IMPL)) + { return true; + } if ((cseLclVarTyp == TYP_I_IMPL) && (expTyp == TYP_BYREF)) + { return true; + } // Otherwise we have incompatible types return false; From 127ba09b6d1ff1a7d9787ec5ea1521d024b237f1 Mon Sep 17 00:00:00 2001 From: Brian Sullivan Date: Thu, 21 Feb 2019 09:53:40 -0800 Subject: [PATCH 3/3] Mispelling Commit migrated from https://github.com/dotnet/coreclr/commit/28dcdac7f0251cd3bfff722030e43901688a70ad --- src/coreclr/src/jit/optcse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/src/jit/optcse.cpp b/src/coreclr/src/jit/optcse.cpp index 688c2092f0d..648e67047cd 100644 --- a/src/coreclr/src/jit/optcse.cpp +++ b/src/coreclr/src/jit/optcse.cpp @@ -1976,7 +1976,7 @@ public: // bool IsCompatibleType(var_types cseLclVarTyp, var_types expTyp) { - // Excat type match is the expected case + // Exact type match is the expected case if (cseLclVarTyp == expTyp) { return true;