Closes dotnet/coreclr#20651.
Also fix up some "near miss" cases for GenTreeField and GenTreeBoundsCheck,
where we get lucky and the importer currently splits trees with temps so the
currently ignored child nodes have no interesting side effects.
Revise GenTreeField a bit to pull more of the initialization work into the
constructor. Add a missing R2R field propagation for field nodes in GtClone
(evidently also never hit in practice).
Commit migrated from https://github.com/dotnet/coreclr/commit/
626def86af589734999a0e62d3a83c2acb9de54a
{
#if SMALL_TREE_NODES
/* 'GT_FIELD' nodes may later get transformed into 'GT_IND' */
-
assert(GenTree::s_gtNodeSizes[GT_IND] <= GenTree::s_gtNodeSizes[GT_FIELD]);
- GenTree* tree = new (this, GT_FIELD) GenTreeField(typ);
-#else
- GenTree* tree = new (this, GT_FIELD) GenTreeField(typ);
-#endif
- tree->gtField.gtFldObj = obj;
- tree->gtField.gtFldHnd = fldHnd;
- tree->gtField.gtFldOffset = offset;
+#endif // SMALL_TREE_NODES
-#ifdef FEATURE_READYTORUN_COMPILER
- tree->gtField.gtFieldLookup.addr = nullptr;
-#endif
+ GenTree* tree = new (this, GT_FIELD) GenTreeField(typ, obj, fldHnd, offset);
// If "obj" is the address of a local, note that a field of that struct local has been accessed.
if (obj != nullptr && obj->OperGet() == GT_ADDR && varTypeIsStruct(obj->gtOp.gtOp1) &&
copy = gtNewFieldRef(tree->TypeGet(), tree->gtField.gtFldHnd, objp, tree->gtField.gtFldOffset);
copy->gtField.gtFldMayOverlap = tree->gtField.gtFldMayOverlap;
+#ifdef FEATURE_READYTORUN_COMPILER
+ copy->gtField.gtFieldLookup = tree->gtField.gtFieldLookup;
+#endif
}
else if (tree->OperIs(GT_ADD, GT_SUB))
{
CORINFO_CONST_LOOKUP gtFieldLookup;
#endif
- GenTreeField(var_types type) : GenTree(GT_FIELD, type)
+ GenTreeField(var_types type, GenTree* obj, CORINFO_FIELD_HANDLE fldHnd, DWORD offs)
+ : GenTree(GT_FIELD, type), gtFldObj(obj), gtFldHnd(fldHnd), gtFldOffset(offs), gtFldMayOverlap(false)
{
- gtFldMayOverlap = false;
+ if (obj != nullptr)
+ {
+ gtFlags |= (obj->gtFlags & GTF_ALL_EFFECT);
+ }
+
+#ifdef FEATURE_READYTORUN_COMPILER
+ gtFieldLookup.addr = nullptr;
+#endif
}
#if DEBUGGABLE_GENTREE
GenTreeField() : GenTree()
: GenTree(oper, type), gtIndex(index), gtArrLen(arrLen), gtIndRngFailBB(nullptr), gtThrowKind(kind)
{
// Effects flags propagate upwards.
+ gtFlags |= (index->gtFlags & GTF_ALL_EFFECT);
gtFlags |= (arrLen->gtFlags & GTF_ALL_EFFECT);
gtFlags |= GTF_EXCEPT;
}
var_types type, GenTree* arr, unsigned char rank, unsigned char elemSize, var_types elemType, GenTree** inds)
: GenTree(GT_ARR_ELEM, type), gtArrObj(arr), gtArrRank(rank), gtArrElemSize(elemSize), gtArrElemType(elemType)
{
+ gtFlags |= (arr->gtFlags & GTF_ALL_EFFECT);
for (unsigned char i = 0; i < rank; i++)
{
gtArrInds[i] = inds[i];
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+class X
+{
+ static string s = "hello, world";
+
+ static string[,] G()
+ {
+ string[,] strings = new string[3,3];
+ strings[0,0] = s;
+ return strings;
+ }
+
+ // Ensure GTF_CALL flag is propagated to MD array accessor
+ public static int Main()
+ {
+ int c = G()[0,0].GetHashCode();
+ int v = s.GetHashCode();
+ return c == v ? 100 : -1;
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <CLRTestPriority>1</CLRTestPriority>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="GitHub_20651.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>
\ No newline at end of file