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

Fixed some alignment differences between LLVM and BeefBE

This commit is contained in:
Brian Fiete 2020-04-03 10:34:26 -07:00
parent 0ae14f5a5d
commit 1ca01864bb
12 changed files with 73 additions and 21 deletions

View file

@ -2540,6 +2540,7 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
if (wasMadeAddr)
useType = mModule->CreatePointerType(useType);
staticValue = CreateGlobalVariable(mModule->mBfIRBuilder->MapType(useType), true, BfIRLinkageType_Internal, staticValue, staticVarName);
GlobalVar_SetAlignment(staticValue, useType->mAlign);
}
int flags = 0;

View file

@ -715,6 +715,7 @@ struct BfGlobalVar
int mStreamId;
BfIRValue mInitializer;
bool mIsTLS;
int mAlignment;
};
struct BfGlobalVar_TypeInst

View file

@ -3312,7 +3312,7 @@ void BfIRCodeGen::HandleNextCmd()
//BF_ASSERT(file != NULL);
llvm::DIExpression* diExpr = NULL;
auto gve = mDIBuilder->createGlobalVariableExpression((llvm::DIScope*)context, name.c_str(), linkageName.c_str(), (llvm::DIFile*)file, lineNum, (llvm::DIType*)type,
isLocalToUnit, diExpr, decl);
isLocalToUnit, diExpr, decl);
if (val != NULL)
{
@ -3320,7 +3320,7 @@ void BfIRCodeGen::HandleNextCmd()
{
globalVar->addDebugInfo(gve);
}
}
}
SetResult(curId, diExpr);
}

View file

@ -3153,6 +3153,7 @@ void BfModule::CreateStaticField(BfFieldInstance* fieldInstance, bool isThreadLo
initValue,
staticVarName,
isThreadLocal);
mBfIRBuilder->GlobalVar_SetAlignment(globalVar, fieldType->mAlign);
BF_ASSERT(globalVar);
mStaticFieldRefs[fieldInstance] = globalVar;
@ -4114,7 +4115,7 @@ BfIRValue BfModule::CreateClassVDataGlobal(BfTypeInstance* typeInstance, int* ou
true,
BfIRLinkageType_External,
BfIRValue(),
classVDataName);
classVDataName);
mClassVDataRefs[typeInstance] = globalVariable;
}
@ -4459,7 +4460,8 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
auto reflectPointerType = ResolveTypeDef(mCompiler->mReflectPointerType)->ToTypeInstance();
auto pointerTypeData = mBfIRBuilder->CreateConstStruct(mBfIRBuilder->MapTypeInst(reflectPointerType, BfIRPopulateType_Full), pointerTypeDataParms);
typeDataVar = mBfIRBuilder->CreateGlobalVariable(mBfIRBuilder->MapTypeInst(reflectPointerType), true,
BfIRLinkageType_External, pointerTypeData, typeDataName);
BfIRLinkageType_External, pointerTypeData, typeDataName);
typeDataVar = mBfIRBuilder->CreateBitCast(typeDataVar, mBfIRBuilder->MapType(mContext->mBfTypeType));
}
else if (type->IsSizedArray())
@ -4487,6 +4489,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
else
typeDataVar = mBfIRBuilder->CreateConstNull(mBfIRBuilder->MapType(mContext->mBfTypeType));
mBfIRBuilder->GlobalVar_SetAlignment(typeDataVar, mSystem->mPtrSize);
mTypeDataRefs[typeInstance] = typeDataVar;
return typeDataVar;