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

LLVM 13 fixes for debug locations and sret/byval

This commit is contained in:
Brian Fiete 2022-02-07 15:15:58 -05:00
parent 3cd91832a8
commit 390f27c072
2 changed files with 20 additions and 22 deletions

View file

@ -3781,9 +3781,9 @@ void BfIRCodeGen::HandleNextCmd()
auto attr = LLVMMapAttribute(attribute);
if (attr == llvm::Attribute::StructRet)
{
// FIXME: StructRet changed from EnumAttr to TypeAttr
//llvm::Attribute sret = llvm::Attribute::getWithStructRetType(*mLLVMContext, srt);
//((llvm::CallInst*)callInst)->addAttribute(argIdx, sret);
auto funcType = ((llvm::CallInst*)callInst)->getFunctionType();
llvm::Attribute sret = llvm::Attribute::getWithStructRetType(*mLLVMContext, funcType->getFunctionParamType(argIdx - 1)->getPointerElementType());
((llvm::CallInst*)callInst)->addAttribute(argIdx, sret);
}
else
{
@ -3806,13 +3806,11 @@ void BfIRCodeGen::HandleNextCmd()
}
else if (attribute == BfIRAttribute_ByVal)
{
// FIXME: Adding integer/type attribute without an argument.
/*llvm::AttrBuilder B;
B.addAttribute(llvm::Attribute::ByVal);
B.addAlignmentAttr(arg);
auto attrList = ((llvm::CallInst*)callInst)->getAttributes();
attrList = attrList.addAttributes(*mLLVMContext, argIdx, B);
((llvm::CallInst*)callInst)->setAttributes(attrList);*/
auto funcType = ((llvm::CallInst*)callInst)->getFunctionType();
llvm::Attribute byValAttr = llvm::Attribute::getWithByValType(*mLLVMContext, funcType->getFunctionParamType(argIdx - 1)->getPointerElementType());
llvm::Attribute alignAttr = llvm::Attribute::getWithAlignment(*mLLVMContext, llvm::Align(arg));
((llvm::CallInst*)callInst)->addAttribute(argIdx, byValAttr);
((llvm::CallInst*)callInst)->addAttribute(argIdx, alignAttr);
}
}
}
@ -3869,9 +3867,9 @@ void BfIRCodeGen::HandleNextCmd()
auto attr = LLVMMapAttribute(attribute);
if (attr == llvm::Attribute::StructRet)
{
// FIXME: StructRet changed from EnumAttr to TypeAttr
//llvm::Attribute sret = llvm::Attribute::getWithStructRetType(*mLLVMContext, srt);
//func->addAttribute(argIdx, sret);
auto funcType = func->getFunctionType();
llvm::Attribute sret = llvm::Attribute::getWithStructRetType(*mLLVMContext, funcType->getFunctionParamType(argIdx - 1)->getPointerElementType());
func->addAttribute(argIdx, sret);
}
else if (attr != llvm::Attribute::None)
func->addAttribute(argIdx, attr);
@ -3890,13 +3888,11 @@ void BfIRCodeGen::HandleNextCmd()
}
else if (attribute == BfIRAttribute_ByVal)
{
// FIXME: Adding integer/type attribute without an argument.
/*llvm::AttrBuilder B;
B.addAttribute(llvm::Attribute::ByVal);
B.addAlignmentAttr(arg);
auto attrList = ((llvm::Function*)func)->getAttributes();
attrList = attrList.addAttributes(*mLLVMContext, argIdx, B);
((llvm::Function*)func)->setAttributes(attrList);*/
auto funcType = func->getFunctionType();
llvm::Attribute byValAttr = llvm::Attribute::getWithByValType(*mLLVMContext, funcType->getFunctionParamType(argIdx - 1)->getPointerElementType());
llvm::Attribute alignAttr = llvm::Attribute::getWithAlignment(*mLLVMContext, llvm::Align(arg));
func->addAttribute(argIdx, byValAttr);
func->addAttribute(argIdx, alignAttr);
}
}
break;

View file

@ -148,6 +148,7 @@ bool BfModule::AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfSc
mBfIRBuilder->SetInsertPointAtStart(mCurMethodState->mIRInitBlock);
auto scopeHead = &mCurMethodState->mHeadScope;
if (scopeHead->mDIScope)
mBfIRBuilder->SetCurrentDebugLocation(mCurFilePosition.mCurLine + 1, 0, scopeHead->mDIScope, BfIRMDNode());
if (WantsLifetimes())
@ -164,6 +165,7 @@ bool BfModule::AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfSc
mBfIRBuilder->SetInsertPoint(mCurMethodState->mIRInitBlock);
if (scopeHead->mDIScope)
mBfIRBuilder->SetCurrentDebugLocation(mCurFilePosition.mCurLine + 1, 0, scopeHead->mDIScope, BfIRMDNode());
mBfIRBuilder->CreateStatementStart();