mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed "over-aligned" issue with global variables
This commit is contained in:
parent
2f6d9e03ab
commit
8102de259f
2 changed files with 28 additions and 0 deletions
|
@ -552,6 +552,31 @@ void BfIRCodeGen::FixValues(llvm::StructType* structType, llvm::SmallVector<llvm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfIRCodeGen::FixValues(llvm::StructType* structType, llvm::SmallVector<llvm::Constant*, 8>& values)
|
||||||
|
{
|
||||||
|
if (values.size() >= structType->getNumElements())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int readIdx = (int)values.size() - 1;
|
||||||
|
values.resize(structType->getNumElements());
|
||||||
|
for (int i = (int)values.size() - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (values[readIdx]->getType() == structType->getElementType(i))
|
||||||
|
{
|
||||||
|
values[i] = values[readIdx];
|
||||||
|
readIdx--;
|
||||||
|
}
|
||||||
|
else if (structType->getElementType(i)->isArrayTy())
|
||||||
|
{
|
||||||
|
values[i] = llvm::ConstantAggregateZero::get(structType->getElementType(i));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BF_FATAL("Malformed structure values");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BfIRCodeGen::FixIndexer(llvm::Value*& val)
|
void BfIRCodeGen::FixIndexer(llvm::Value*& val)
|
||||||
{
|
{
|
||||||
if ((int)val->getType()->getScalarSizeInBits() > mPtrSize * 8)
|
if ((int)val->getType()->getScalarSizeInBits() > mPtrSize * 8)
|
||||||
|
@ -1285,6 +1310,8 @@ void BfIRCodeGen::Read(BfIRTypedValue& typedValue, BfIRCodeGenEntry** codeGenEnt
|
||||||
}
|
}
|
||||||
else if (auto structType = llvm::dyn_cast<llvm::StructType>(type->mLLVMType))
|
else if (auto structType = llvm::dyn_cast<llvm::StructType>(type->mLLVMType))
|
||||||
{
|
{
|
||||||
|
FixValues(structType, values);
|
||||||
|
|
||||||
for (int i = 0; i < (int)values.size(); i++)
|
for (int i = 0; i < (int)values.size(); i++)
|
||||||
{
|
{
|
||||||
if (values[i]->getType() != structType->getElementType(i))
|
if (values[i]->getType() != structType->getElementType(i))
|
||||||
|
|
|
@ -178,6 +178,7 @@ public:
|
||||||
public:
|
public:
|
||||||
void InitTarget();
|
void InitTarget();
|
||||||
void FixValues(llvm::StructType* structType, llvm::SmallVector<llvm::Value*, 8>& values);
|
void FixValues(llvm::StructType* structType, llvm::SmallVector<llvm::Value*, 8>& values);
|
||||||
|
void FixValues(llvm::StructType* structType, llvm::SmallVector<llvm::Constant*, 8>& values);
|
||||||
void FixIndexer(llvm::Value*& val);
|
void FixIndexer(llvm::Value*& val);
|
||||||
void FixTypedValue(BfIRTypedValue& typedValue);
|
void FixTypedValue(BfIRTypedValue& typedValue);
|
||||||
BfTypeCode GetTypeCode(llvm::Type* type, bool isSigned);
|
BfTypeCode GetTypeCode(llvm::Type* type, bool isSigned);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue