1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-10 10:00:57 +09:00

Various no-diff cleanups and debugging additions/fixes (#96200)

* Various no-diff cleanups and debugging additions

1. Add debugging cVN/dVN dumpers of value numbers
2. Fix new loop debugging dumpers on x86
3. Display the bbID, not just bbNum, in more places
4. For ValueNum handle constants, display the handle constant type
5. Fix some grammar nits and try to rewrite some comments to read better

* Code review feedback

Have function `GenTree::gtGetHandleKindString` to return handle string;
let the caller print it.
This commit is contained in:
Bruce Forstall 2023-12-21 10:27:07 -08:00 committed by GitHub
parent 30c65646b9
commit 83239262d5
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 179 additions and 192 deletions

View file

@ -4017,66 +4017,66 @@ ValueNum ValueNumStore::EvalCastForConstantArgs(var_types typ, VNFunc func, Valu
}
break;
}
{
#ifdef TARGET_64BIT
case TYP_REF:
case TYP_BYREF:
case TYP_REF:
case TYP_BYREF:
#endif
case TYP_LONG:
INT64 arg0Val = GetConstantInt64(arg0VN);
assert(!checkedCast || !CheckedOps::CastFromLongOverflows(arg0Val, castToType, srcIsUnsigned));
case TYP_LONG:
{
INT64 arg0Val = GetConstantInt64(arg0VN);
assert(!checkedCast || !CheckedOps::CastFromLongOverflows(arg0Val, castToType, srcIsUnsigned));
switch (castToType)
switch (castToType)
{
case TYP_BYTE:
assert(typ == TYP_INT);
return VNForIntCon(INT8(arg0Val));
case TYP_UBYTE:
assert(typ == TYP_INT);
return VNForIntCon(UINT8(arg0Val));
case TYP_SHORT:
assert(typ == TYP_INT);
return VNForIntCon(INT16(arg0Val));
case TYP_USHORT:
assert(typ == TYP_INT);
return VNForIntCon(UINT16(arg0Val));
case TYP_INT:
assert(typ == TYP_INT);
return VNForIntCon(INT32(arg0Val));
case TYP_UINT:
assert(typ == TYP_INT);
return VNForIntCon(UINT32(arg0Val));
case TYP_LONG:
case TYP_ULONG:
assert(typ == TYP_LONG);
return arg0VN;
case TYP_BYREF:
assert(typ == TYP_BYREF);
return VNForByrefCon((target_size_t)arg0Val);
case TYP_FLOAT:
assert(typ == TYP_FLOAT);
if (srcIsUnsigned)
{
case TYP_BYTE:
assert(typ == TYP_INT);
return VNForIntCon(INT8(arg0Val));
case TYP_UBYTE:
assert(typ == TYP_INT);
return VNForIntCon(UINT8(arg0Val));
case TYP_SHORT:
assert(typ == TYP_INT);
return VNForIntCon(INT16(arg0Val));
case TYP_USHORT:
assert(typ == TYP_INT);
return VNForIntCon(UINT16(arg0Val));
case TYP_INT:
assert(typ == TYP_INT);
return VNForIntCon(INT32(arg0Val));
case TYP_UINT:
assert(typ == TYP_INT);
return VNForIntCon(UINT32(arg0Val));
case TYP_LONG:
case TYP_ULONG:
assert(typ == TYP_LONG);
return arg0VN;
case TYP_BYREF:
assert(typ == TYP_BYREF);
return VNForByrefCon((target_size_t)arg0Val);
case TYP_FLOAT:
assert(typ == TYP_FLOAT);
if (srcIsUnsigned)
{
return VNForFloatCon(FloatingPointUtils::convertUInt64ToFloat(UINT64(arg0Val)));
}
else
{
return VNForFloatCon(float(arg0Val));
}
case TYP_DOUBLE:
assert(typ == TYP_DOUBLE);
if (srcIsUnsigned)
{
return VNForDoubleCon(FloatingPointUtils::convertUInt64ToDouble(UINT64(arg0Val)));
}
else
{
return VNForDoubleCon(double(arg0Val));
}
default:
unreached();
return VNForFloatCon(FloatingPointUtils::convertUInt64ToFloat(UINT64(arg0Val)));
}
else
{
return VNForFloatCon(float(arg0Val));
}
case TYP_DOUBLE:
assert(typ == TYP_DOUBLE);
if (srcIsUnsigned)
{
return VNForDoubleCon(FloatingPointUtils::convertUInt64ToDouble(UINT64(arg0Val)));
}
else
{
return VNForDoubleCon(double(arg0Val));
}
default:
unreached();
}
}
case TYP_FLOAT:
{
float arg0Val = GetConstantSingle(arg0VN);
@ -6062,10 +6062,12 @@ bool ValueNumStore::IsVNNeverNegative(ValueNum vn)
GenTreeFlags ValueNumStore::GetHandleFlags(ValueNum vn)
{
assert(IsVNHandle(vn));
Chunk* c = m_chunks.GetNoExpand(GetChunkNum(vn));
unsigned offset = ChunkOffset(vn);
VNHandle* handle = &reinterpret_cast<VNHandle*>(c->m_defs)[offset];
return handle->m_flags;
Chunk* c = m_chunks.GetNoExpand(GetChunkNum(vn));
unsigned offset = ChunkOffset(vn);
VNHandle* handle = &reinterpret_cast<VNHandle*>(c->m_defs)[offset];
const GenTreeFlags handleFlags = handle->m_flags;
assert((handleFlags & ~GTF_ICON_HDL_MASK) == 0);
return handleFlags;
}
GenTreeFlags ValueNumStore::GetFoldedArithOpResultHandleFlags(ValueNum vn)
@ -6114,7 +6116,7 @@ bool ValueNumStore::IsVNHandle(ValueNum vn)
bool ValueNumStore::IsVNObjHandle(ValueNum vn)
{
return IsVNHandle(vn) && GetHandleFlags(vn) == GTF_ICON_OBJ_HDL;
return IsVNHandle(vn) && (GetHandleFlags(vn) == GTF_ICON_OBJ_HDL);
}
//------------------------------------------------------------------------
@ -8928,8 +8930,9 @@ void ValueNumStore::vnDump(Compiler* comp, ValueNum vn, bool isPtr)
}
else if (IsVNHandle(vn))
{
ssize_t val = ConstantValue<ssize_t>(vn);
printf("Hnd const: 0x%p", dspPtr(val));
ssize_t val = ConstantValue<ssize_t>(vn);
const GenTreeFlags handleFlags = GetHandleFlags(vn);
printf("Hnd const: 0x%p %s", dspPtr(val), GenTree::gtGetHandleKindString(handleFlags));
}
else if (IsVNConstant(vn))
{
@ -8972,7 +8975,7 @@ void ValueNumStore::vnDump(Compiler* comp, ValueNum vn, bool isPtr)
}
else
{
printf("LngCns: ");
printf("LngCns");
if ((val > -1000) && (val < 1000))
{
printf(" %ld", val);
@ -10577,8 +10580,8 @@ void Compiler::fgValueNumberRegisterConstFieldSeq(GenTreeIntCon* tree)
//------------------------------------------------------------------------
// fgValueNumberStore: Does value numbering for a store.
//
// While this methods does indeed give a VN to the store tree itself, its
// main objective is to update the various state that holds values, i. e.
// While this method does indeed give a VN to the store tree itself, its
// main objective is to update the various state that holds values, i.e.
// the per-SSA VNs for tracked variables and the heap states for analyzable
// (to fields and arrays) stores.
//