🌐
LLVM
llvm.org › doxygen › classllvm_1_1Function.html
LLVM: llvm::Function Class Reference
This value is always defined to be zero to allow easy checking for whether a function is intrinsic or not. The particular intrinsic functions which correspond to this value are defined in llvm/Intrinsics.h.
🌐
LLVM
llvm.org › doxygen › classllvm_1_1FunctionType.html
LLVM: llvm::FunctionType Class Reference
Class to represent function types. Definition at line 105 of file DerivedTypes.h. Definition at line 128 of file DerivedTypes.h. Methods for support type inquiry through isa, cast, and dyn_cast. Definition at line 147 of file DerivedTypes.h. References llvm::Type::FunctionTyID, T, and llvm::Type::Type().
🌐
LLVM
llvm.org › doxygen › group__LLVMCCoreValueFunctionParameters.html
LLVM: Function Parameters
Obtain the next parameter to a function. This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is actually a wrapped iterator) and obtains the next parameter from the underlying iterator.
🌐
LLVM
llvm.org › docs › LangRef.html
LLVM Language Reference Manual — LLVM 23.0.0git documentation
May 12, 2026 - LLVM programs are composed of Module’s, each of which is a translation unit of the input programs. Each module consists of functions, global variables, and symbol table entries. Modules may be combined together with the LLVM linker, which merges function (and global variable) definitions, resolves forward declarations, and merges symbol table entries.
🌐
LLVM
releases.llvm.org › 2.6 › docs › tutorial › JITTutorial1.html
LLVM Tutorial 1: A First Function
October 24, 2009 - For starters, let's consider a relatively straightforward function that takes three integer parameters and returns an arithmetic combination of them. This is nice and simple, especially since it involves no control flow: int mul_add(int x, int y, int z) { return x * y + z; } As a preview, the LLVM ...
🌐
LLVM
llvm.org › doxygen › group__LLVMCCoreTypeFunction.html
LLVM: Function Types
The function is defined as a tuple of a return Type, a list of parameter types, and whether the function is variadic. Definition at line 779 of file Core.cpp. References llvm::FunctionType::get(), llvm::unwrap(), and llvm::wrap().
🌐
mcyoung
mcyoung.xyz › 2023 › 08 › 01 › llvm-ir
A Gentle Introduction to LLVM IR · mcyoung
The body of a function resembles assembly: a list of labels and instructions. Unlike ordinary assembly, however, there are significant restrictions on the structure of these instructions. In this case, there is only one instruction: a void-typed return. Unlike most assembly languages, LLVM IR is strongly typed, and requires explicit type annotations almost everywhere.
🌐
Readthedocs
mapping-high-level-constructs-to-llvm-ir.readthedocs.io › en › latest › basic-constructs › functions.html
Function Definitions and Declarations — Mapping High Level Constructs to LLVM IR documentation
int function(int a, int b) { return a + b; } double function(double a, double b, double x) { return a*b + x; } For LLVM these two are completely different functions, with different names etc.
Find elsewhere
🌐
Hdoc
docs.hdoc.io › hdoc › llvm-project › rADBA2A8E0906EC47.html
class Function: LLVM/Clang 15.x documentation
This is an important base class in LLVM. It provides the common facilities of all constant values in an LLVM program. A constant is a value that is immutable at runtime. Functions are constants because their address is immutable. Same with global variables. All constants share the capabilities provided in this class.
Top answer
1 of 1
12

From the "Kaleidoscope: Code generation to LLVM IR" manual: http://llvm.org/docs/tutorial/LangImpl3.html

3.4. Function Code Generation

Code generation for prototypes and functions must handle a number of details, which make their code less beautiful than expression code generation, but allows us to illustrate some important points. First, lets talk about code generation for prototypes: they are used both for function bodies and external function declarations. The code starts with:

Function *PrototypeAST::Codegen() {
  // Make the function type:  double(double,double) etc.
  std::vector<Type*> Doubles(Args.size(),
                             Type::getDoubleTy(getGlobalContext()));
  FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()),
                                       Doubles, false);

  Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);

Later, when you want to add IR to the function you should get its declaration from the module: TheModule->getFunction(Name); and add a BasicBlock:

BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
Builder.SetInsertPoint(BB);

PS: answer is untested and answerer is not expert in LLVM.

PPS: For InlineAsm function, as I think after doing searches with MetaGer, you can't declare function as cited from Kaleidoscope. The only way is to have InlineAsm function created at the place of call. Example of such usage is here: CyanogenMod/android/art/compiler/llvm/runtime_support_builder_x86.cc#44

44 Value* RuntimeSupportBuilderX86::EmitGetCurrentThread() {
45  Function* ori_func = GetRuntimeSupportFunction(runtime_support::GetCurrentThread);
          //  ^^^^^ this is used only to know right Type of Function.
46  std::string inline_asm(StringPrintf("mov %%fs:%d, $0", Thread::SelfOffset().Int32Value()));  // <<< define the body of InlineAsm
47  InlineAsm* func = InlineAsm::get(ori_func->getFunctionType(), inline_asm, "=r", false);  // << Create InlineAsm function
48  CallInst* thread = irb_.CreateCall(func); // << Call it
🌐
Readthedocs
llvmlite.readthedocs.io › en › latest › user-guide › ir › examples.html
Example—defining a simple function — llvmlite 0.49.0dev0+18.g6302ab2.dirty documentation
April 30, 2026 - module = ir.Module(name=__file__) # and declare a function named "fpadd" inside it func = ir.Function(module, fnty, name="fpadd") # Now implement the function block = func.append_basic_block(name="entry") builder = ir.IRBuilder(block) a, b = func.args result = builder.fadd(a, b, name="res") builder.ret(result) # Print the module IR print(module) The generated LLVM intermediate representation is printed at the end:
🌐
Jonathan2251
jonathan2251.github.io › lbd › funccall.html
Function call — Tutorial: Creating an LLVM Backend for the Cpu0 Architecture
On the other hand, functions implicitly used by LLVM, such as memcpy, belong to “texternalsym”. The memcpy function is typically generated when defining a long string. The file ch9_1_2.cpp is an example that triggers a call to memcpy.
🌐
LLVM
llvm.org › doxygen › group__LLVMCCoreValueFunction.html
LLVM: Function values
References F, llvm::unwrap(), and llvm::wrap(). ... Obtain the calling function of a function.
🌐
LLVM
llvm.org › doxygen › classllvm_1_1MachineFunction.html
LLVM: llvm::MachineFunction Class Reference
/ CreateMachineBasicBlock - Allocate a new MachineBasicBlock. Use this / instead of ‘new MachineBasicBlock’. Sets MachineBasicBlock::BBID if basic-block-sections is enabled for the function. Definition at line 506 of file MachineFunction.cpp. References llvm::List, and MBB.
🌐
Gatech
cs6340.cc.gatech.edu › LLVM8Doxygen › group__LLVMCCoreValueFunctionParameters.html
LLVM: Function Parameters
Obtain the next parameter to a function. This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is actually a wrapped iterator) and obtains the next parameter from the underlying iterator.
🌐
LLVM
llvm.org › docs › ProgrammersManual.html
LLVM Programmer’s Manual — LLVM 23.0.0git documentation
Unlike both printf and Python, it additionally fails to compile if LLVM does not know how to format the type. These two properties ensure that the function is both safer and simpler to use than traditional formatting methods such as the printf family of functions.
🌐
Urho3D
docs.huihoo.com › doxygen › llvm › 20140918 › classllvm_1_1Function.html
llvm::Function Class Reference - Huihoo
References llvm::iplist< NodeTy, Traits >::begin(). Definition at line 300 of file Function.cpp.