It is a pointer to Value. Try cast<>ing it to ConstantInt and then calling getValue():
for(auto arg = fn->arg_begin(); arg != fn->arg_end(); ++arg) {
if(auto* ci = dyn_cast<ConstantInt>(arg))
errs() << ci->getValue() << "\n";
errs() << *arg << "\n";
}
Answer from arrowd on Stack OverflowLLVM
llvm.org › doxygen › group__LLVMCCoreValueFunctionParameters.html
LLVM: Function Parameters
References llvm::Function::arg_begin(), llvm::unwrap(), and llvm::wrap(). ... Obtain the function to which this argument belongs.
LLVM
llvm.org › doxygen › classllvm_1_1Argument.html
LLVM: llvm::Argument Class Reference
Return the index of this formal argument in its containing function. For example in "void foo(int a, float b)" a is 0 and b is 1. Definition at line 50 of file Argument.h. References assert(). Referenced by AddParamAndFnBasicAttributes(), createOutlinedFunction(), llvm::AMDGPU::HSAMD::MetadataStreamerMsgPackV4::emitKernelArg(), findArgParts(), llvm::AbstractCallSite::getCallArgOperand(), llvm::AbstractCallSite::getCallArgOperandNo(), isArgUnmodifiedByAllCalls(), and llvm::Attributor::registerFunctionSignatureRewrite().
LLVM
llvm.org › doxygen › classllvm_1_1Function.html
LLVM: llvm::Function Class Reference
Definition at line 283 of file ... llvm::CallingConv::SPIR_KERNEL. hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand, so that the list isn't allocated until the first client needs it....
Jonathan2251
jonathan2251.github.io › lbd › funccall.html
Function call — Tutorial: Creating an LLVM Backend for the Cpu0 Architecture
... 0. Program arguments: /Users/Jonathan/llvm/test/build/ bin/llc -march=cpu0 -relocation-model=pic -filetype=asm ch9_1.bc -o ch9_1.cpu0.s 1. Running pass 'Function Pass Manager' on module 'ch9_1.bc'. 2.
Hdoc
docs.hdoc.io › hdoc › llvm-project › rADBA2A8E0906EC47.html
class Function: LLVM/Clang 15.x documentation
public void viewCFGOnly(const llvm::BlockFrequencyInfo * BFI, const llvm::BranchProbabilityInfo * BPI) const ... Creates a new function and attaches it to a module. Places the function in the program address space as specified by the module's data layout. ... Function ctor - If the (optional) Module argument is specified, the function is automatically inserted into the end of the function list for the module.
Stack Overflow
stackoverflow.com › questions › 41350749 › accessing-arguments-to-llvm-function-attributes
clang - Accessing arguments to llvm function attributes - Stack Overflow
Even though I set the functions' attribute argument to an increasing counter beginning at 1, I still get outputs as such: Found member function named: _ZN8simple_t8getValueEv with function ID: 0 · The LLVM IR has the following attribute data for this function:
Wilfred
wilfred.me.uk › llvm › tutorial › LangImpl03.html
3. Kaleidoscope: Code generation to LLVM IR — LLVM 3.9 documentation
April 19, 2016 - Note first that this function returns a “Function*” instead of a “Value*”. Because a “prototype” really talks about the external interface for a function (not the value computed by an expression), it makes sense for it to return the LLVM Function it corresponds to when codegen’d. The call to FunctionType::get creates the FunctionType that should be used for a given Prototype. Since all function arguments in Kaleidoscope are of type double, the first line creates a vector of “N” LLVM double types.
LLVM Discussion Forums
discourse.llvm.org › ir & optimizations
LLVM function argument analysis - IR & Optimizations - LLVM Discussion Forums
July 8, 2022 - I have a simple function on which I am trying to detect whether the memory access instructions refer to the function arguments. I am trying to do it using the MemoryLocation::get() function and then dyn_cast the pointer to the Argument class. This all works fine if I run the analysis on IR ...
LLVM
llvm.org › docs › LangRef.html
LLVM Language Reference Manual — LLVM 23.0.0git documentation
May 12, 2026 - The argument must be the value returned by the appropriate llvm.call.preallocated.arg on non musttail calls, or the corresponding caller parameter in musttail calls, although it is ignored during codegen. A non musttail function call with a preallocated attribute in any parameter must have a "preallocated" operand bundle.
LLVM Discussion Forums
discourse.llvm.org › beginners
Passing function value as a function argument - Beginners - LLVM Discussion Forums
April 16, 2023 - I am building a compiler for Scheme using LLVM with the Rust programming language. I would like to know if I can pass “Function Value” type as a function parameter? This is required for me to pass a function object as a parameter to a function call. Here is the link to the relevant code.
Packtpub
subscription.packtpub.com › book › application-development › 9781785280801 › 2 › ch02lvl1sec160 › emitting-function-arguments
Emitting function arguments
Access over 7,500 Programming & Development eBooks and videos to advance your IT skills. Enjoy unlimited access to over 100 new titles every month on the latest technologies and trends
Hackage
hackage.haskell.org › package › LibClang-3.4.0 › src › llvm › lib › Transforms › IPO › DeadArgumentElimination.cpp
Haskell
This is only for use /// by bugpoint. struct DAH : public DAE { static char ID; DAH() : DAE(ID) {} virtual bool ShouldHackArguments() const { return true; } }; } char DAH::ID = 0; INITIALIZE_PASS(DAH, "deadarghaX0r", "Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)", false, false) /// createDeadArgEliminationPass - This pass removes arguments from functions /// which are not used by the body of the function. /// ModulePass *llvm::createDeadArgEliminationPass() { return new DAE(); } ModulePass *llvm::createDeadArgHackingPass() { return new DAH(); } /// CollectFunctionDIs - Map each function in the module to its debug info /// descriptor.
LLVM
lists.llvm.org › pipermail › llvm-dev › 2011-January › 037534.html
[LLVMdev] How to get the name and argument of a function
January 19, 2011 - >>>> There's a worked example at >>>> http://wiki.llvm.org/HowTo:_Find_all_call_sites_of_a_function . >>>> >>>> With the CallInst/InvokeInst you can query getArgOperand() to get the >>>> arguments or getCallee() which return a Function -- or it might not. If >>>> the call is an indirect call (ie., function pointer) then you don't >>>> know >>>> what it's calling.