@@ -7726,8 +7726,8 @@ GenTreeFlags Compiler::gtTokenToIconFlags(unsigned token)
7726
7726
// Returns a GT_IND node representing value at the address provided by 'addr'
7727
7727
//
7728
7728
// Notes:
7729
- // The GT_IND node is marked as non-faulting
7730
- // If the indType is GT_REF we also mark the indNode as GTF_GLOB_REF
7729
+ // The GT_IND node is marked as non-faulting.
7730
+ // If the indirection is not invariant, we also mark the indNode as GTF_GLOB_REF.
7731
7731
//
7732
7732
GenTree* Compiler::gtNewIndOfIconHandleNode(var_types indType, size_t addr, GenTreeFlags iconFlags, bool isInvariant)
7733
7733
{
@@ -7736,9 +7736,7 @@ GenTree* Compiler::gtNewIndOfIconHandleNode(var_types indType, size_t addr, GenT
7736
7736
7737
7737
if (isInvariant)
7738
7738
{
7739
- assert(iconFlags != GTF_ICON_STATIC_HDL); // Pointer to a mutable class Static variable
7740
- assert(iconFlags != GTF_ICON_BBC_PTR); // Pointer to a mutable basic block count value
7741
- assert(iconFlags != GTF_ICON_GLOBAL_PTR); // Pointer to mutable data from the VM state
7739
+ assert(GenTree::HandleKindDataIsInvariant(iconFlags));
7742
7740
7743
7741
// This indirection also is invariant.
7744
7742
indirFlags |= GTF_IND_INVARIANT;
@@ -10814,6 +10812,27 @@ void GenTree::SetIndirExceptionFlags(Compiler* comp)
10814
10812
}
10815
10813
}
10816
10814
10815
+ //------------------------------------------------------------------------------
10816
+ // HandleKindDataIsInvariant: Returns true if the data referred to by a handle
10817
+ // address is guaranteed to be invariant. Note that GTF_ICON_FTN_ADDR handles may
10818
+ // or may not point to invariant data.
10819
+ //
10820
+ // Arguments:
10821
+ // flags - GenTree flags for handle.
10822
+ //
10823
+ /* static */
10824
+ bool GenTree::HandleKindDataIsInvariant(GenTreeFlags flags)
10825
+ {
10826
+ GenTreeFlags handleKind = flags & GTF_ICON_HDL_MASK;
10827
+ assert(handleKind != GTF_EMPTY);
10828
+
10829
+ // All handle types are assumed invariant except those specifically listed here.
10830
+
10831
+ return (handleKind != GTF_ICON_STATIC_HDL) && // Pointer to a mutable class Static variable
10832
+ (handleKind != GTF_ICON_BBC_PTR) && // Pointer to a mutable basic block count value
10833
+ (handleKind != GTF_ICON_GLOBAL_PTR); // Pointer to mutable data from the VM state
10834
+ }
10835
+
10817
10836
#ifdef DEBUG
10818
10837
10819
10838
/* static */ int GenTree::gtDispFlags(GenTreeFlags flags, GenTreeDebugFlags debugFlags)
0 commit comments