summaryrefslogtreecommitdiff
path: root/src/jit
diff options
context:
space:
mode:
authorKyungwoo Lee <kyulee@microsoft.com>2016-03-04 13:18:08 -0800
committerKyungwoo Lee <kyulee@microsoft.com>2016-03-08 08:56:13 -0800
commitc7b3805184af2a9e6e59baec4a5a8d238af1c4e4 (patch)
tree93c07301ae5f6049332c772f2f5d6051aab2b484 /src/jit
parente22d5d34d1b32b32443880338e7e9a2a92a16487 (diff)
downloadcoreclr-c7b3805184af2a9e6e59baec4a5a8d238af1c4e4.tar.gz
coreclr-c7b3805184af2a9e6e59baec4a5a8d238af1c4e4.tar.bz2
coreclr-c7b3805184af2a9e6e59baec4a5a8d238af1c4e4.zip
Fix for casting byref to double in morph
This fixes https://github.com/dotnet/coreclr/issues/3517. JIT didn't cast byref to double in morph, which caused this assertion later. The fix is to handle such case as well.
Diffstat (limited to 'src/jit')
-rw-r--r--src/jit/morph.cpp36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp
index 16ece5f76f..3858a20d25 100644
--- a/src/jit/morph.cpp
+++ b/src/jit/morph.cpp
@@ -502,34 +502,22 @@ GenTreePtr Compiler::fgMorphCast(GenTreePtr tree)
// it believes the variable is a GC variable at the begining of the
// instruction group, but is not turned non-gc by the code generator
// we fix this by copying the GC pointer to a non-gc pointer temp.
- if (varTypeIsFloating(srcType) == varTypeIsFloating(dstType))
- {
- noway_assert(!varTypeIsGC(dstType) && "How can we have a cast to a GCRef here?");
-
- // We generate an assignment to an int and then do the cast from an int. With this we avoid
- // the gc problem and we allow casts to bytes, longs, etc...
- var_types typInter;
- typInter = TYP_I_IMPL;
+ noway_assert(!varTypeIsGC(dstType) && "How can we have a cast to a GCRef here?");
- unsigned lclNum = lvaGrabTemp(true DEBUGARG("Cast away GC"));
- oper->gtType = typInter;
- GenTreePtr asg = gtNewTempAssign(lclNum, oper);
- oper->gtType = srcType;
+ // We generate an assignment to an int and then do the cast from an int. With this we avoid
+ // the gc problem and we allow casts to bytes, longs, etc...
+ unsigned lclNum = lvaGrabTemp(true DEBUGARG("Cast away GC"));
+ oper->gtType = TYP_I_IMPL;
+ GenTreePtr asg = gtNewTempAssign(lclNum, oper);
+ oper->gtType = srcType;
- // do the real cast
- GenTreePtr cast = gtNewCastNode(tree->TypeGet(), gtNewLclvNode(lclNum, typInter), dstType);
+ // do the real cast
+ GenTreePtr cast = gtNewCastNode(tree->TypeGet(), gtNewLclvNode(lclNum, TYP_I_IMPL), dstType);
- // Generate the comma tree
- oper = gtNewOperNode(GT_COMMA, tree->TypeGet(), asg, cast);
+ // Generate the comma tree
+ oper = gtNewOperNode(GT_COMMA, tree->TypeGet(), asg, cast);
- return fgMorphTree(oper);
- }
- else
- {
- tree->gtCast.CastOp() = fgMorphTree(oper);
- tree->gtFlags |= (tree->gtCast.CastOp()->gtFlags & GTF_ALL_EFFECT);
- return tree;
- }
+ return fgMorphTree(oper);
}
// Look for narrowing casts ([u]long -> [u]int) and try to push them