mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Order-independent hash fixes
This commit is contained in:
parent
2ea5d31c37
commit
d41a8c5683
3 changed files with 97 additions and 6 deletions
|
@ -241,6 +241,12 @@ BeIRCodeGen::~BeIRCodeGen()
|
||||||
|
|
||||||
void BeIRCodeGen::Hash(BeHashContext& hashCtx)
|
void BeIRCodeGen::Hash(BeHashContext& hashCtx)
|
||||||
{
|
{
|
||||||
|
// if (mBeModule->mModuleName == "IDE_IDEApp")
|
||||||
|
// {
|
||||||
|
// hashCtx.mDbgViz = true;
|
||||||
|
// NOP;
|
||||||
|
// }
|
||||||
|
|
||||||
hashCtx.Mixin(mPtrSize);
|
hashCtx.Mixin(mPtrSize);
|
||||||
hashCtx.Mixin(mIsOptimized);
|
hashCtx.Mixin(mIsOptimized);
|
||||||
if (mBeModule != NULL)
|
if (mBeModule != NULL)
|
||||||
|
@ -2782,6 +2788,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
|
|
||||||
if (dbgFunc->mValue != NULL)
|
if (dbgFunc->mValue != NULL)
|
||||||
dbgFunc->mValue->mDbgFunction = dbgFunc;
|
dbgFunc->mValue->mDbgFunction = dbgFunc;
|
||||||
|
dbgFunc->mIdx = (int)mBeModule->mDbgModule->mFuncs.size();
|
||||||
mBeModule->mDbgModule->mFuncs.push_back(dbgFunc);
|
mBeModule->mDbgModule->mFuncs.push_back(dbgFunc);
|
||||||
|
|
||||||
SetResult(curId, dbgFunc);
|
SetResult(curId, dbgFunc);
|
||||||
|
@ -2823,6 +2830,7 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
}*/
|
}*/
|
||||||
if (dbgFunc->mValue != NULL)
|
if (dbgFunc->mValue != NULL)
|
||||||
dbgFunc->mValue->mDbgFunction = dbgFunc;
|
dbgFunc->mValue->mDbgFunction = dbgFunc;
|
||||||
|
dbgFunc->mIdx = (int)mBeModule->mDbgModule->mFuncs.size();
|
||||||
mBeModule->mDbgModule->mFuncs.push_back(dbgFunc);
|
mBeModule->mDbgModule->mFuncs.push_back(dbgFunc);
|
||||||
|
|
||||||
SetResult(curId, dbgFunc);
|
SetResult(curId, dbgFunc);
|
||||||
|
|
|
@ -3264,9 +3264,89 @@ void BeDbgModule::HashContent(BeHashContext & hashCtx)
|
||||||
hashCtx.MixinStr(mDirectory);
|
hashCtx.MixinStr(mDirectory);
|
||||||
hashCtx.MixinStr(mProducer);
|
hashCtx.MixinStr(mProducer);
|
||||||
|
|
||||||
for (auto dbgFunc : mFuncs)
|
BeDumpContext dc;
|
||||||
dbgFunc->HashReference(hashCtx);
|
dc.mModule = mBeModule;
|
||||||
|
String lhsName;
|
||||||
|
String rhsName;
|
||||||
|
|
||||||
for (auto globalVar : mGlobalVariables)
|
if (!mFuncs.IsEmpty())
|
||||||
globalVar->HashReference(hashCtx);
|
{
|
||||||
|
auto _GetName = [&](BeDbgFunction* func, String& str)
|
||||||
|
{
|
||||||
|
if (!func->mLinkageName.IsEmpty())
|
||||||
|
str.Append(func->mLinkageName);
|
||||||
|
else
|
||||||
|
dc.ToString(str, func);
|
||||||
|
};
|
||||||
|
|
||||||
|
Array<BeDbgFunction*> unrefFuncs;
|
||||||
|
for (auto dbgFunc : mFuncs)
|
||||||
|
{
|
||||||
|
if ((!dbgFunc->mIncludedAsMember) && (dbgFunc->mHashId == -1))
|
||||||
|
unrefFuncs.Add(dbgFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(unrefFuncs.begin(), unrefFuncs.end(), [&](BeDbgFunction* lhs, BeDbgFunction* rhs)
|
||||||
|
{
|
||||||
|
lhsName.Clear();
|
||||||
|
_GetName(lhs, lhsName);
|
||||||
|
|
||||||
|
rhsName.Clear();
|
||||||
|
_GetName(rhs, rhsName);
|
||||||
|
|
||||||
|
int cmp = String::Compare(lhsName, rhsName, false);
|
||||||
|
if (cmp != 0)
|
||||||
|
return cmp < 0;
|
||||||
|
|
||||||
|
if (lhs->mFile != rhs->mFile)
|
||||||
|
{
|
||||||
|
lhsName.Clear();
|
||||||
|
rhsName.Clear();
|
||||||
|
if (lhs->mFile != NULL)
|
||||||
|
lhs->mFile->ToString(lhsName);
|
||||||
|
if (rhs->mFile != NULL)
|
||||||
|
rhs->mFile->ToString(rhsName);
|
||||||
|
cmp = String::Compare(lhsName, rhsName, false);
|
||||||
|
if (cmp != 0)
|
||||||
|
return cmp < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lhs->mLine != rhs->mLine)
|
||||||
|
return lhs->mLine < rhs->mLine;
|
||||||
|
|
||||||
|
return lhs->mIdx < rhs->mIdx;
|
||||||
|
});
|
||||||
|
|
||||||
|
hashCtx.Mixin(unrefFuncs.size());
|
||||||
|
for (auto dbgFunc : unrefFuncs)
|
||||||
|
{
|
||||||
|
if (dbgFunc->mHashId == -1)
|
||||||
|
dbgFunc->HashReference(hashCtx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mGlobalVariables.IsEmpty())
|
||||||
|
{
|
||||||
|
auto _GetName = [&](BeDbgGlobalVariable* func, String& str)
|
||||||
|
{
|
||||||
|
if (!func->mLinkageName.IsEmpty())
|
||||||
|
str.Append(func->mLinkageName);
|
||||||
|
else
|
||||||
|
dc.ToString(str, func);
|
||||||
|
};
|
||||||
|
|
||||||
|
std::sort(mGlobalVariables.begin(), mGlobalVariables.end(), [&](BeDbgGlobalVariable* lhs, BeDbgGlobalVariable* rhs)
|
||||||
|
{
|
||||||
|
lhsName.Clear();
|
||||||
|
_GetName(lhs, lhsName);
|
||||||
|
|
||||||
|
rhsName.Clear();
|
||||||
|
_GetName(rhs, rhsName);
|
||||||
|
|
||||||
|
return (lhsName < rhsName);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto globalVar : mGlobalVariables)
|
||||||
|
globalVar->HashReference(hashCtx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1764,6 +1764,8 @@ public:
|
||||||
BE_VALUE_TYPE(BeDbgFunction, BeMDNode);
|
BE_VALUE_TYPE(BeDbgFunction, BeMDNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
int mIdx;
|
||||||
|
|
||||||
BeMDNode* mScope;
|
BeMDNode* mScope;
|
||||||
BeDbgFile* mFile;
|
BeDbgFile* mFile;
|
||||||
int mLine;
|
int mLine;
|
||||||
|
@ -1793,6 +1795,7 @@ public:
|
||||||
public:
|
public:
|
||||||
BeDbgFunction()
|
BeDbgFunction()
|
||||||
{
|
{
|
||||||
|
mIdx = -1;
|
||||||
mScope = NULL;
|
mScope = NULL;
|
||||||
mFile = NULL;
|
mFile = NULL;
|
||||||
mLine = -1;
|
mLine = -1;
|
||||||
|
@ -2009,8 +2012,8 @@ public:
|
||||||
virtual void HashContent(BeHashContext& hashCtx) override
|
virtual void HashContent(BeHashContext& hashCtx) override
|
||||||
{
|
{
|
||||||
hashCtx.Mixin(TypeId);
|
hashCtx.Mixin(TypeId);
|
||||||
hashCtx.Mixin(mName);
|
hashCtx.MixinStr(mName);
|
||||||
hashCtx.Mixin(mLinkageName);
|
hashCtx.MixinStr(mLinkageName);
|
||||||
if (mFile != NULL)
|
if (mFile != NULL)
|
||||||
mFile->HashReference(hashCtx);
|
mFile->HashReference(hashCtx);
|
||||||
hashCtx.Mixin(mLineNum);
|
hashCtx.Mixin(mLineNum);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue