Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSingleAccretion <62474226+SingleAccretion@users.noreply.github.com>2022-02-22 18:37:25 +0300
committerGitHub <noreply@github.com>2022-02-22 18:37:25 +0300
commit4ff711f33652d423b3f3d2472674951407e4130d (patch)
tree2526f45b9ab2e621cd410d7918d682d4ce3b4045 /src
parent3079505a45cce88b9a4d9ef55b50c9944c5c412c (diff)
Do not set GLOB_REF for invariant indirections (#65709)
The GTF_GLOB_REF flag in the compiler has the meaning that the node marked with it produces a value that could be modified by a call or an indirect store. It is used for optimizations that need to know whether it is safe to reorder two trees. Invariant indirections, by definition, always produce the same value, and as such do not need to be marked with GLOB_REF. Some nice diffs from args sorting: string literals can now be put in the "late args" list directly (without a temp).
Diffstat (limited to 'src')
-rw-r--r--src/coreclr/jit/gentree.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp
index afa6c78d308..0a90ce3e143 100644
--- a/src/coreclr/jit/gentree.cpp
+++ b/src/coreclr/jit/gentree.cpp
@@ -5821,19 +5821,6 @@ GenTree* Compiler::gtNewIndOfIconHandleNode(var_types indType, size_t addr, GenT
//
indNode->gtFlags |= GTF_IND_NONFAULTING;
- // String Literal handles are indirections that return a TYP_REF, and
- // these are pointers into the GC heap. We don't currently have any
- // TYP_BYREF pointers, but if we did they also must be pointers into the GC heap.
- //
- // Also every GTF_ICON_STATIC_HDL also must be a pointer into the GC heap
- // we will set GTF_GLOB_REF for these kinds of references.
- //
- if ((varTypeIsGC(indType)) || (iconFlags == GTF_ICON_STATIC_HDL))
- {
- // This indirection also points into the gloabal heap
- indNode->gtFlags |= GTF_GLOB_REF;
- }
-
if (isInvariant)
{
assert(iconFlags != GTF_ICON_STATIC_HDL); // Pointer to a mutable class Static variable
@@ -5849,6 +5836,13 @@ GenTree* Compiler::gtNewIndOfIconHandleNode(var_types indType, size_t addr, GenT
indNode->gtFlags |= GTF_IND_NONNULL;
}
}
+ else
+ {
+ // GLOB_REF needs to be set for indirections returning values from mutable
+ // locations, so that e. g. args sorting does not reorder them with calls.
+ indNode->gtFlags |= GTF_GLOB_REF;
+ }
+
return indNode;
}