1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Fixes for ShowWrongHash, looking into debug info issues in opt llvm

This commit is contained in:
Brian Fiete 2019-09-24 08:58:04 -07:00
parent c67fbd66ba
commit 54d5884213
8 changed files with 69 additions and 34 deletions

View file

@ -34,7 +34,7 @@ namespace Beefy.theme.dark
public bool mHasClosed; public bool mHasClosed;
public Insets mRelWidgetMouseInsets ~ delete _; public Insets mRelWidgetMouseInsets ~ delete _;
public bool mAllowMouseInsideSelf; public bool mAllowMouseInsideSelf;
public bool mRequireMouseInside; public bool mAllowMouseOutside;
public const float cShadowSize = 8; public const float cShadowSize = 8;
@ -224,7 +224,7 @@ namespace Beefy.theme.dark
if (mWidgetWindow == null) if (mWidgetWindow == null)
return; return;
if (!mRequireMouseInside) if (mAllowMouseOutside)
return; return;
float rootX; float rootX;

View file

@ -6182,6 +6182,10 @@ namespace IDE
sourceViewPanel.SetLoadCmd(loadCmd); sourceViewPanel.SetLoadCmd(loadCmd);
} }
} }
else if ((hash != .None) && (hash != sourceViewPanel.mLoadedHash))
{
sourceViewPanel.ShowWrongHash();
}
int showHotIdx = -1; int showHotIdx = -1;
if (!onlyShowCurrent) if (!onlyShowCurrent)
@ -11408,6 +11412,7 @@ namespace IDE
continue; continue;
//TODO: Check to see if this file is in the dependency list of the executing project //TODO: Check to see if this file is in the dependency list of the executing project
if (!editData.mProjectSources.IsEmpty)
mHaveSourcesChangedExternallySinceLastCompile = true; mHaveSourcesChangedExternallySinceLastCompile = true;
editData.SetSavedData(null, IdSpan()); editData.SetSavedData(null, IdSpan());

View file

@ -2022,7 +2022,7 @@ namespace IDE.ui
if (!mClosed) if (!mClosed)
{ {
if ((DarkTooltipManager.sTooltip != null) && (!DarkTooltipManager.sTooltip.mRequireMouseInside)) if ((DarkTooltipManager.sTooltip != null) && (DarkTooltipManager.sTooltip.mAllowMouseOutside))
DarkTooltipManager.CloseTooltip(); DarkTooltipManager.CloseTooltip();
if (IsInPanel()) if (IsInPanel())

View file

@ -2729,7 +2729,7 @@ namespace IDE.ui
{ {
if (mWidgetWindow.IsKeyDown(.Control)) if (mWidgetWindow.IsKeyDown(.Control))
{ {
if ((DarkTooltipManager.sTooltip != null) && (!DarkTooltipManager.sTooltip.mRequireMouseInside)) if ((DarkTooltipManager.sTooltip != null) && (DarkTooltipManager.sTooltip.mAllowMouseOutside))
DarkTooltipManager.CloseTooltip(); DarkTooltipManager.CloseTooltip();
gApp.mSettings.mTutorialsFinished.mCtrlCursor = true; gApp.mSettings.mTutorialsFinished.mCtrlCursor = true;
} }
@ -2739,7 +2739,7 @@ namespace IDE.ui
let tooltip = DarkTooltipManager.ShowTooltip("Hold CTRL when using UP and DOWN", this, cursorX - GS!(24), cursorY - GS!(40)); let tooltip = DarkTooltipManager.ShowTooltip("Hold CTRL when using UP and DOWN", this, cursorX - GS!(24), cursorY - GS!(40));
if (tooltip != null) if (tooltip != null)
tooltip.mRequireMouseInside = false; tooltip.mAllowMouseOutside = true;
return; return;
} }
} }

View file

@ -303,6 +303,8 @@ namespace IDE.ui
{ {
switch (lhs) switch (lhs)
{ {
case .None:
return rhs case .None;
case .MD5(let lhsMD5): case .MD5(let lhsMD5):
if (rhs case .MD5(let rhsMD5)) if (rhs case .MD5(let rhsMD5))
return lhsMD5 == rhsMD5; return lhsMD5 == rhsMD5;
@ -3106,7 +3108,7 @@ namespace IDE.ui
ResizeComponents(); ResizeComponents();
} }
void ShowWrongHash() public void ShowWrongHash()
{ {
CloseHeader(); CloseHeader();
@ -3335,6 +3337,38 @@ namespace IDE.ui
CheckBinary(); CheckBinary();
} }
void CheckAdjustFile()
{
if (mLoadedHash == .None)
return;
String text = scope .();
if (File.ReadAllText(mFilePath, text, true) case .Err)
return;
SourceHash textHash = SourceHash.Create(mLoadedHash.GetKind(), text);
if (textHash == mLoadedHash)
return;
if (text.Contains('\r'))
{
text.Replace("\r", "");
}
else
{
text.Replace("\n", "\r\n");
}
textHash = SourceHash.Create(mLoadedHash.GetKind(), text);
if (textHash == mLoadedHash)
{
if (File.WriteAllText(mFilePath, text) case .Err)
{
gApp.mFileWatcher.OmitFileChange(mFilePath, text);
return;
}
}
}
void RetryLoad() void RetryLoad()
{ {
var prevHash = mLoadedHash; var prevHash = mLoadedHash;
@ -5386,6 +5420,7 @@ namespace IDE.ui
{ {
if ((int)mOldVerLoadExecutionInstance.mExitCode == 0) if ((int)mOldVerLoadExecutionInstance.mExitCode == 0)
{ {
CheckAdjustFile();
RetryLoad(); RetryLoad();
} }
else else
@ -5403,6 +5438,7 @@ namespace IDE.ui
if (result == .Failed) if (result == .Failed)
gApp.OutputErrorLine("Failed to retrieve source from {}", mOldVerLoadCmd); gApp.OutputErrorLine("Failed to retrieve source from {}", mOldVerLoadCmd);
CheckAdjustFile();
RetryLoad(); RetryLoad();
DeleteAndNullify!(mOldVerHTTPRequest); DeleteAndNullify!(mOldVerHTTPRequest);
} }

View file

@ -4989,7 +4989,7 @@ void COFF::CvParseIPI()
int offset = dataOffset; int offset = dataOffset;
for (int idx = 0; idx < recordCount; idx++) for (int idx = 0; idx < recordCount; idx++)
{ {
BF_ASSERT(((offset) & 3) == 0); //BF_ASSERT(((offset) & 3) == 0);
uint8* data = mCvIPIReader.GetTempPtr(offset, 4); uint8* data = mCvIPIReader.GetTempPtr(offset, 4);
uint16 trLength = GET(uint16); uint16 trLength = GET(uint16);
int offsetStart = offset; int offsetStart = offset;

View file

@ -1,5 +1,6 @@
#include "BfIRCodeGen.h" #include "BfIRCodeGen.h"
#include "BfModule.h" #include "BfModule.h"
#include "BeefySysLib/util/BeefPerf.h"
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4141) #pragma warning(disable:4141)
@ -4057,6 +4058,19 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
} }
bool success = PM.run(*mLLVMModule); bool success = PM.run(*mLLVMModule);
if ((codeGenOptions.mOptLevel > BfOptLevel_O0) && (codeGenOptions.mWriteLLVMIR))
{
BP_ZONE("BfCodeGen::RunLoop.LLVM.IR");
String fileName = outFileName;
int dotPos = (int)fileName.LastIndexOf('.');
if (dotPos != -1)
fileName.RemoveToEnd(dotPos);
fileName += "_OPT.ll";
String irError;
WriteIR(fileName, irError);
}
} }
return true; return true;

View file

@ -1611,30 +1611,7 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
localDef->mAddr = AllocLocalVariable(resolvedType, localDef->mName); localDef->mAddr = AllocLocalVariable(resolvedType, localDef->mName);
} }
// if ((!hadVarType) && (varDecl->mInitializer != NULL)) bool wantsStore = false;
// {
// if (exprEvaluator != NULL)
// {
// if ((initValue) && (initValue.mType->IsNullable()))
// {
// auto boolType = GetPrimitiveType(BfTypeCode_Boolean);
// initValue = LoadValue(initValue);
// exprEvaluator->mResult = BfTypedValue(mBfIRBuilder->CreateExtractValue(initValue.mValue, 2), boolType);
// handledExprBoolResult = true;
//
// if (!resolvedType->IsNullable())
// initValue = BfTypedValue(mBfIRBuilder->CreateExtractValue(initValue.mValue, 1), initValue.mType->GetUnderlyingType());
// }
// else if (initValue)
// {
// TryInitVar(varDecl, &localDef, initValue, exprEvaluator->mResult);
// handledExprBoolResult = true;
// handledVarStore = true;
// handledVarInit = true;
// }
// }
// }
if ((initValue) && (!handledVarStore) && (!isConst) && (!initHandled)) if ((initValue) && (!handledVarStore) && (!isConst) && (!initHandled))
{ {
initValue = LoadValue(initValue); initValue = LoadValue(initValue);
@ -1651,7 +1628,7 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
localDef->mValue = initValue.mValue; localDef->mValue = initValue.mValue;
if ((localDef->mAddr) && (!localDef->mResolvedType->IsValuelessType())) if ((localDef->mAddr) && (!localDef->mResolvedType->IsValuelessType()))
{ {
mBfIRBuilder->CreateStore(initValue.mValue, localDef->mAddr); wantsStore = true;
} }
else else
{ {
@ -1727,7 +1704,10 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
if (localDef->mConstValue) if (localDef->mConstValue)
initType = BfIRInitType_NotNeeded; initType = BfIRInitType_NotNeeded;
return AddLocalVariableDef(localDef, true, false, BfIRValue(), initType); BfLocalVariable* localVar = AddLocalVariableDef(localDef, true, false, BfIRValue(), initType);
if (wantsStore)
mBfIRBuilder->CreateStore(initValue.mValue, localVar->mAddr);
return localVar;
} }
BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varDecl, BfTypedValue val, bool updateSrcLoc, bool forceAddr) BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varDecl, BfTypedValue val, bool updateSrcLoc, bool forceAddr)