1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +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); auto attr = LLVMMapAttribute(attribute);
if (attr == llvm::Attribute::StructRet) if (attr == llvm::Attribute::StructRet)
{ {
// FIXME: StructRet changed from EnumAttr to TypeAttr auto funcType = ((llvm::CallInst*)callInst)->getFunctionType();
//llvm::Attribute sret = llvm::Attribute::getWithStructRetType(*mLLVMContext, srt); llvm::Attribute sret = llvm::Attribute::getWithStructRetType(*mLLVMContext, funcType->getFunctionParamType(argIdx - 1)->getPointerElementType());
//((llvm::CallInst*)callInst)->addAttribute(argIdx, sret); ((llvm::CallInst*)callInst)->addAttribute(argIdx, sret);
} }
else else
{ {
@ -3806,13 +3806,11 @@ void BfIRCodeGen::HandleNextCmd()
} }
else if (attribute == BfIRAttribute_ByVal) else if (attribute == BfIRAttribute_ByVal)
{ {
// FIXME: Adding integer/type attribute without an argument. auto funcType = ((llvm::CallInst*)callInst)->getFunctionType();
/*llvm::AttrBuilder B; llvm::Attribute byValAttr = llvm::Attribute::getWithByValType(*mLLVMContext, funcType->getFunctionParamType(argIdx - 1)->getPointerElementType());
B.addAttribute(llvm::Attribute::ByVal); llvm::Attribute alignAttr = llvm::Attribute::getWithAlignment(*mLLVMContext, llvm::Align(arg));
B.addAlignmentAttr(arg); ((llvm::CallInst*)callInst)->addAttribute(argIdx, byValAttr);
auto attrList = ((llvm::CallInst*)callInst)->getAttributes(); ((llvm::CallInst*)callInst)->addAttribute(argIdx, alignAttr);
attrList = attrList.addAttributes(*mLLVMContext, argIdx, B);
((llvm::CallInst*)callInst)->setAttributes(attrList);*/
} }
} }
} }
@ -3869,9 +3867,9 @@ void BfIRCodeGen::HandleNextCmd()
auto attr = LLVMMapAttribute(attribute); auto attr = LLVMMapAttribute(attribute);
if (attr == llvm::Attribute::StructRet) if (attr == llvm::Attribute::StructRet)
{ {
// FIXME: StructRet changed from EnumAttr to TypeAttr auto funcType = func->getFunctionType();
//llvm::Attribute sret = llvm::Attribute::getWithStructRetType(*mLLVMContext, srt); llvm::Attribute sret = llvm::Attribute::getWithStructRetType(*mLLVMContext, funcType->getFunctionParamType(argIdx - 1)->getPointerElementType());
//func->addAttribute(argIdx, sret); func->addAttribute(argIdx, sret);
} }
else if (attr != llvm::Attribute::None) else if (attr != llvm::Attribute::None)
func->addAttribute(argIdx, attr); func->addAttribute(argIdx, attr);
@ -3890,13 +3888,11 @@ void BfIRCodeGen::HandleNextCmd()
} }
else if (attribute == BfIRAttribute_ByVal) else if (attribute == BfIRAttribute_ByVal)
{ {
// FIXME: Adding integer/type attribute without an argument. auto funcType = func->getFunctionType();
/*llvm::AttrBuilder B; llvm::Attribute byValAttr = llvm::Attribute::getWithByValType(*mLLVMContext, funcType->getFunctionParamType(argIdx - 1)->getPointerElementType());
B.addAttribute(llvm::Attribute::ByVal); llvm::Attribute alignAttr = llvm::Attribute::getWithAlignment(*mLLVMContext, llvm::Align(arg));
B.addAlignmentAttr(arg); func->addAttribute(argIdx, byValAttr);
auto attrList = ((llvm::Function*)func)->getAttributes(); func->addAttribute(argIdx, alignAttr);
attrList = attrList.addAttributes(*mLLVMContext, argIdx, B);
((llvm::Function*)func)->setAttributes(attrList);*/
} }
} }
break; break;

View file

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