From ec4abbf159e5989303b09dc2d4d9d4d033863b2e Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Wed, 19 Mar 2025 14:07:38 -0700 Subject: [PATCH 1/2] expose Function::getFunctionType to LLVM c api --- llvm/include/llvm-c/Core.h | 7 +++++++ llvm/lib/IR/Core.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h index a414e2061a595..b8f54d02514ef 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -3016,6 +3016,13 @@ LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); */ LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); +/** + * Obtain function type. + * + * @see llvm::Function::getFunctionType() + */ +LLVMTypeRef LLVMGetFunctionType(LLVMValueRef Fn); + /** * Obtain the next parameter to a function. * diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index f4b03e8cb8aa3..69dba1c2f7966 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -2658,6 +2658,10 @@ void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) { A->addAttr(Attribute::getWithAlignment(A->getContext(), Align(align))); } +LLVMTypeRef LLVMGetFunctionType(LLVMValueRef Fn) { + return wrap(unwrap(Fn)->getFunctionType()); +} + /*--.. Operations on ifuncs ................................................--*/ LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M, From 65d37292ed30183128f3f0ac152294e9978317ed Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Wed, 19 Mar 2025 14:14:24 -0700 Subject: [PATCH 2/2] revert changes, update comment --- llvm/include/llvm-c/Core.h | 8 +------- llvm/lib/IR/Core.cpp | 4 ---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h index b8f54d02514ef..871e5eb8457d7 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -2543,6 +2543,7 @@ void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr); * type of a global value which is always a pointer type. * * @see llvm::GlobalValue::getValueType() + * @see llvm::Function::getFunctionType() */ LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global); @@ -3016,13 +3017,6 @@ LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); */ LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); -/** - * Obtain function type. - * - * @see llvm::Function::getFunctionType() - */ -LLVMTypeRef LLVMGetFunctionType(LLVMValueRef Fn); - /** * Obtain the next parameter to a function. * diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 69dba1c2f7966..f4b03e8cb8aa3 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -2658,10 +2658,6 @@ void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) { A->addAttr(Attribute::getWithAlignment(A->getContext(), Align(align))); } -LLVMTypeRef LLVMGetFunctionType(LLVMValueRef Fn) { - return wrap(unwrap(Fn)->getFunctionType()); -} - /*--.. Operations on ifuncs ................................................--*/ LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,