-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix IMGREL32 static field addr value-num blindspot #6889
Conversation
@dotnet/jit-contrib PTAL. SPMI reports only one asm diff, and jit-diff reports none, but I think that's really due to using System;
using System.Diagnostics;
class ArrayPerf
{
private static int[] m_arr;
private const int MAX_ARRAY_SIZE = 4096;
private static readonly int DIM_1 = MAX_ARRAY_SIZE;
static void Main(string[] args)
{
long iterations = Int64.Parse(args[0]);
int value;
m_arr = new int[DIM_1];
for (int i = 0; i < DIM_1; i++)
m_arr[i] = i;
for (int j = 0; j < DIM_1; j++)
value = m_arr[j];
//var sw = Stopwatch.StartNew();
for (long i = 0; i < iterations; i++)
{
for (int j = 0; j < DIM_1; j++)
{
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
value = m_arr[j];
}
}
//sw.Stop();
//Console.WriteLine(sw.ElapsedMilliseconds);
}
} When compiled during |
} | ||
else if (OperGet() == GT_CNS_INT && gtIntCon.gtFieldSeq != nullptr) | ||
{ | ||
newFldSeq = gtIntCon.gtFieldSeq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a static field and isFieldStatic(newFldSeq->m_fieldHnd))
returns true then you
may need to set baseAddr to 'this' I think as returning both pObj and pStatic as nullptr could be a problem.
Look into this area I can't tell for sure.
The method comment says it isn't allowed, but valuenum 5822 looks like it handles this case.
But if returning both as nullptr is what you want here, then update the comment in the method declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks, I think you're right and pStatic
should be set in this case. Updated.
f011e5a
to
7986216
Compare
@dotnet-bot retest Ubuntu x64 Checked Build and Test |
@dotnet-bot test OSX x64 Checked Build and Test |
7986216
to
399ee3a
Compare
When `fgMorphField` lowers a static field reference for which `eeGetRelocTypeHint` returns `IMAGE_REL_BASED_REL32`, it creates an `IntCon`, flagged with `GFT_ICON_STATIC_HDL` and marked with the static field in its `gtFieldSeq` field, to represent the field's address (as opposed to the normal case where it generates a `ClsVar`). This change updates the `IsFieldAddr` helper used by value-numbering/loop-hoisting to recognize such constants as the appropriate field address, which then allows the disambiguation/tracking of accesses to these fields to kick in as it does for `ClsVar` nodes. Also update test GC/Scenarios/FinalizeTimeout to mark a bool volatile that otherwise can get hoisted (the test aims to observe finalization from a side-effect-free busy-loop by communicating through this bool). Fixes #6900.
399ee3a
to
e4cb4dd
Compare
@dotnet-bot test Linux ARM Emulator Cross Release Build |
Test GC/Scenarios/FinalizeTimeout was failing because it has a side-effect-free busy-loop checking a static variable for a change it expects a finalizer to make to it; with this change the jit recognizes the load as invariant and hoists it out of the loop, I've fixed the test by marking the static field volatile. @briansull PTAL. |
@briansull, any more concerns with this change? I'm not entirely sure what the callers handling a return of two nullptrs are trying to do, but at any rate my intent was to match the ClsVar case and so I set |
Looks Good |
Fix IMGREL32 static field addr value-num blindspot Commit migrated from dotnet/coreclr@2008454
When
fgMorphField
lowers a static field reference for whicheeGetRelocTypeHint
returnsIMAGE_REL_BASED_REL32
, it creates anIntCon
, flagged withGFT_ICON_STATIC_HDL
and marked with the staticfield in its
gtFieldSeq
field, to represent the field's address (asopposed to the normal case where it generates a
ClsVar
). This changeupdates the
IsFieldAddr
helper used by value-numbering/loop-hoisting torecognize such constants as the appropriate field address, which then
allows the disambiguation/tracking of accesses to these fields to kick in
as it does for
ClsVar
nodes.