1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Improved handling of mGhostDependencies. Codegen Abort

This commit is contained in:
Brian Fiete 2025-01-19 08:39:46 -08:00
parent 9988dec99d
commit a82cc0534d
6 changed files with 37 additions and 4 deletions

View file

@ -1124,6 +1124,9 @@ void BeIRCodeGen::Read(BeMDNode*& llvmMD)
void BeIRCodeGen::HandleNextCmd()
{
if (mFailed)
return;
int curId = mCmdCount;
BfIRCmd cmd = (BfIRCmd)mStream->Read();
@ -1192,6 +1195,11 @@ void BeIRCodeGen::HandleNextCmd()
mBeModule->print(outStream, NULL);*/
}
break;
case BfIRCmd_Abort:
{
Fail("Stream aborted");
}
break;
case BfIRCmd_SetType:
{
CMD_PARAM(int, typeId);
@ -1236,6 +1244,13 @@ void BeIRCodeGen::HandleNextCmd()
CMD_PARAM(int, instSize);
CMD_PARAM(int, instAlign);
CMD_PARAM(bool, isPacked);
if ((type == NULL) || (type->mTypeCode != BeTypeCode_Struct))
{
Fail("StructSetBody invalid type");
break;
}
BF_ASSERT(type->mTypeCode == BeTypeCode_Struct);
auto structType = (BeStructType*)type;
mBeContext->SetStructBody(structType, members, isPacked);

View file

@ -2217,6 +2217,12 @@ void BfIRBuilder::WriteIR(const StringImpl& fileName)
NEW_CMD_INSERTED;
}
void BfIRBuilder::AbortStream()
{
WriteCmd(BfIRCmd_Abort);
NEW_CMD_INSERTED;
}
void BfIRBuilder::Module_SetTargetTriple(const StringImpl& targetTriple, const StringImpl& targetCPU)
{
WriteCmd(BfIRCmd_Module_SetTargetTriple, targetTriple, targetCPU);
@ -2774,7 +2780,11 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDbgDefine)
if (!type->IsDeclared())
populateModule->PopulateType(type, BfPopulateType_Declaration);
BF_ASSERT(type->IsDeclared());
if (!type->IsDeclared())
{
AbortStream();
return;
}
#ifdef BFIR_RENTRY_CHECK
ReEntryCheck reEntryCheck(&mDeclReentrySet, type);

View file

@ -161,6 +161,7 @@ enum BfIRCmd : uint8
BfIRCmd_Module_SetTargetTriple,
BfIRCmd_Module_AddModuleFlag,
BfIRCmd_WriteIR,
BfIRCmd_Abort,
BfIRCmd_SetType,
BfIRCmd_SetInstType,
@ -1199,6 +1200,7 @@ public:
void SetBackend(bool isBeefBackend);
void RemoveIRCodeGen();
void WriteIR(const StringImpl& fileName);
void AbortStream();
void Module_SetTargetTriple(const StringImpl& targetTriple, const StringImpl& targetCPU);
void Module_AddModuleFlag(const StringImpl& flag, int val);

View file

@ -2029,6 +2029,9 @@ void BfIRCodeGen::InitTarget()
void BfIRCodeGen::HandleNextCmd()
{
if (mFailed)
return;
int curId = mCmdCount;
BfIRCmd cmd = (BfIRCmd)mStream->Read();
@ -2091,6 +2094,9 @@ void BfIRCodeGen::HandleNextCmd()
mLLVMModule->print(outStream, NULL);
}
break;
case BfIRCmd_Abort:
Fail("Stream aborted");
break;
case BfIRCmd_SetType:
{
CMD_PARAM(int, typeId);

View file

@ -11097,7 +11097,7 @@ BfMethodInstance* BfModule::GetRawMethodInstanceAtIdx(BfTypeInstance* typeInstan
{
if (mCompiler->EnsureCeUnpaused(typeInstance))
{
BF_FATAL("OOB in GetRawMethodInstanceAtIdx");
InternalError("OOB in GetRawMethodInstanceAtIdx");
}
return NULL;
}