Skip to content

Commit

Permalink
Properly type primary selectors in fgMemoryVNForLoopSideEffects (#6…
Browse files Browse the repository at this point in the history
…0505)

* Proper types in fgMemoryVNForLoopSideEffects

To simplify our model for what types the memory maps should
have and, in the future, enable asserts acting on that.

* Switch to only typing statics

As these are the only maps that represent values
representable and useful in the Jit's type system.
  • Loading branch information
SingleAccretion committed Oct 27, 2021
1 parent 760a76b commit fdec73a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7981,6 +7981,9 @@ class Compiler

bool eeIsValueClass(CORINFO_CLASS_HANDLE clsHnd);
bool eeIsJitIntrinsic(CORINFO_METHOD_HANDLE ftn);
bool eeIsFieldStatic(CORINFO_FIELD_HANDLE fldHnd);

var_types eeGetFieldType(CORINFO_FIELD_HANDLE fldHnd);

#if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) || defined(TRACK_LSRA_STATS)

Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/jit/ee_il_dll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ bool Compiler::eeIsJitIntrinsic(CORINFO_METHOD_HANDLE ftn)
return info.compCompHnd->isJitIntrinsic(ftn);
}

FORCEINLINE
bool Compiler::eeIsFieldStatic(CORINFO_FIELD_HANDLE fldHnd)
{
return info.compCompHnd->isFieldStatic(fldHnd);
}

FORCEINLINE
var_types Compiler::eeGetFieldType(CORINFO_FIELD_HANDLE fldHnd)
{
return JITtype2varType(info.compCompHnd->getFieldType(fldHnd));
}

FORCEINLINE
void Compiler::eeGetSig(unsigned sigTok,
CORINFO_MODULE_HANDLE scope,
Expand Down
6 changes: 5 additions & 1 deletion src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6980,8 +6980,12 @@ ValueNum Compiler::fgMemoryVNForLoopSideEffects(MemoryKind memoryKind,
}
#endif // DEBUG

// Instance field maps get the placeholder TYP_REF - they do not represent "singular"
// values. Static field maps, on the other hand, do, and so must be given proper types.
var_types fldMapType = eeIsFieldStatic(fldHnd) ? eeGetFieldType(fldHnd) : TYP_REF;

newMemoryVN =
vnStore->VNForMapStore(TYP_REF, newMemoryVN, fldHndVN, vnStore->VNForExpr(entryBlock, TYP_REF));
vnStore->VNForMapStore(TYP_REF, newMemoryVN, fldHndVN, vnStore->VNForExpr(entryBlock, fldMapType));
}
}
// Now do the array maps.
Expand Down

0 comments on commit fdec73a

Please sign in to comment.