未验证 提交 c302b7b9 编写于 作者: J Jakob Botsch Nielsen 提交者: GitHub

JIT: Fix STORE_DYN_BLK morphing (#73844)

Make sure to properly call SetIndirExceptionFlags and to properly mark defs (that will otherwise hit asserts in rationalization).
上级 3824cb29
......@@ -7541,6 +7541,8 @@ GenTree* Compiler::gtNewStructVal(ClassLayout* layout, GenTree* addr)
blkNode = gtNewObjNode(layout, addr);
}
blkNode->SetIndirExceptionFlags(this);
return blkNode;
}
......
......@@ -1550,14 +1550,18 @@ GenTree* Compiler::fgMorphStoreDynBlock(GenTreeStoreDynBlk* tree)
if (size != 0)
{
GenTree* lhs = gtNewBlockVal(tree->Addr(), static_cast<unsigned>(size));
lhs->SetIndirExceptionFlags(this);
GenTree* asg = gtNewAssignNode(lhs, tree->Data());
asg->gtFlags |= (tree->gtFlags & (GTF_ALL_EFFECT | GTF_BLK_VOLATILE | GTF_BLK_UNALIGNED));
INDEBUG(asg->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED);
JITDUMP("MorphStoreDynBlock: transformed STORE_DYN_BLK into ASG(BLK, Data())\n");
GenTree* lclVarTree = fgIsIndirOfAddrOfLocal(lhs);
if (lclVarTree != nullptr)
{
lclVarTree->gtFlags |= GTF_VAR_DEF;
}
return tree->OperIsCopyBlkOp() ? fgMorphCopyBlock(asg) : fgMorphInitBlock(asg);
}
}
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.CompilerServices;
unsafe class Runtime_73821
{
public struct S
{
public int F;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static S Test1(int val)
{
S s;
int size = sizeof(S);
Unsafe.CopyBlockUnaligned(&s, &val, (uint)size);
return s;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static int Test2(int val)
{
int val2;
int size = sizeof(int);
Unsafe.CopyBlockUnaligned(&val2, &val, (uint)size);
return val2;
}
static int Main()
{
return Test1(33).F + Test2(67);
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Optimize>True</Optimize>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册