Better compatibility with LLVM < 13 (#319)

* Update wrapper to add type attribute on LLVM < 13
This commit is contained in:
Christoffer Lerno
2021-11-09 22:53:13 +01:00
committed by GitHub
parent 137b474f44
commit df0b1df1df
4 changed files with 19 additions and 9 deletions

View File

@@ -111,6 +111,20 @@ static bool llvm_link(ObjFormat format, const char **args, int arg_count, const
extern "C" {
#if LLVM_VERSION_MAJOR < 13
#if _MSC_VER
__declspec(selectany)
#else
__attribute__((weak))
#endif
LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,
LLVMTypeRef type_ref)
{
auto &Ctx = *llvm::unwrap(C);
auto AttrKind = (llvm::Attribute::AttrKind)KindID;
return wrap(llvm::Attribute::get(Ctx, AttrKind, llvm::unwrap(type_ref)));
}
#endif
LLVMValueRef LLVMConstBswap(LLVMValueRef ConstantVal)
{
llvm::Constant *Val = llvm::unwrap<llvm::Constant>(ConstantVal);