diff options
author | sivarv <sivarv@microsoft.com> | 2017-03-07 17:15:47 -0800 |
---|---|---|
committer | sivarv <sivarv@microsoft.com> | 2017-03-07 17:22:09 -0800 |
commit | f6b9eb39d97cc0a2cf26b73574a0c38e226d4e0b (patch) | |
tree | 8507663809d0b4607f8a4fd71758c9d978f53e50 | |
parent | d67517364d978ab233ed767020c9581b44f8dc75 (diff) | |
download | coreclr-f6b9eb39d97cc0a2cf26b73574a0c38e226d4e0b.tar.gz coreclr-f6b9eb39d97cc0a2cf26b73574a0c38e226d4e0b.tar.bz2 coreclr-f6b9eb39d97cc0a2cf26b73574a0c38e226d4e0b.zip |
Morph assert fix.
-rw-r--r-- | src/jit/morph.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index 3eb565a192..80ba2ddc36 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -17251,10 +17251,30 @@ Compiler::fgWalkResult Compiler::fgMorphStructField(GenTreePtr tree, fgWalkData* tree->gtFlags &= ~GTF_GLOB_REF; GenTreePtr parent = fgWalkPre->parentStack->Index(1); - if ((parent->gtOper == GT_ASG) && (parent->gtOp.gtOp1 == tree)) + if (parent->gtOper == GT_ASG) { - tree->gtFlags |= GTF_VAR_DEF; - tree->gtFlags |= GTF_DONT_CSE; + if (parent->gtOp.gtOp1 == tree) + { + tree->gtFlags |= GTF_VAR_DEF; + tree->gtFlags |= GTF_DONT_CSE; + } + + // Promotion of struct containing struct fields where the field + // is a struct with a single pointer sized scalar type field: in + // this case struct promotion uses the type of the underlying + // scalar field as the type of struct field instead of recursively + // promoting. This can lead to a case where we have a block-asgn + // with its RHS replaced with a scalar type. Mark RHS value as + // DONT_CSE so that assertion prop will not do const propagation. + // The reason this is required is that if RHS of a block-asg is a + // constant, then it is interpreted as init-block incorrectly. + // + // TODO - This can also be avoided if we implement recursive struct + // promotion. + if (varTypeIsStruct(parent) && parent->gtOp.gtOp2 == tree && !varTypeIsStruct(tree)) + { + tree->gtFlags |= GTF_DONT_CSE; + } } #ifdef DEBUG if (verbose) |