[LLVMdev] Functions with unnamed parameters in LLVM IR
Tim Northover
t.p.northover at gmail.com
Wed Aug 13 07:48:44 PDT 2014
> The above LLVM IR was confusing to me because I usually see that
> unnamed registers start counting from 1 (i.e. %1 = add ...).
There's a (usually hidden) %0 representing the entry basic block
there. The general rule is "start from 0 and keep counting; skip named
values".
> I'm slightly surprised that unnamed function arguments are allowed at
> all. Maybe there is a use case but I can't think of a good one off the
> top of my head.
They're useful for ensuring ABI conformance: padding out (hardware)
registers that you don't want to use for a particular call.
You might map void foo(int32_t a, int64_t b) to "declare void @foo(i32
%a, i32, i64 %b)" for example, if your 64-bit value had to start at an
even (32-bit) register number, as is the case on ARM. (Actually, it's
not necessary there, but is in more complicated cases).
> I think it should be documented in the LLVM reference manual what the
> register names are for unnamed arguments.
It does sound reasonable to add a note that function arguments get
included too, since they're not obviously value computations.
Cheers.
Tim.
More information about the llvm-dev
mailing list