[llvm-dev] Arguments name IR LLVM

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 29 04:39:21 PDT 2019


Hi Mohamed,

On Mon, 29 Jul 2019 at 12:09, mohamed messelka via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> As we see, the argument has no name, if we look at call function in main function we see the arguments name (a, b and c):
>
> call void @vecadd(i32 10, float* getelementptr inbounds ([10 x float], [10 x float]* @a, i64 0, i64 0), float* getelementptr inbounds ([10 x float], [10 x float]* @b, i64 0, i64 0), float* nonnull %3)

Some kind of name, but not a good one for a couple of reasons: it'll
vary between callsites, and may not even be referencable in @vecadd
itself if it's a local name to the caller.

> The problem is, how can I get arguments name from the instruction inside define function because I just have the instructions in define function.

When names are omitted in LLVM, it starts assigning them automatically
by counting up %0, %1, .... A function's (unnamed) arguments will
always start at %0 so in that case it's pretty easy to calculate the
proper value. In more complicated cases you'd use the class
"ModuleSlotTracker" to compute it for you, but that's really not very
efficient.

But the chances are pretty good that you don't need the name anyway.
It's only really useful for debug output, and not generally worth the
hassle of computing manually even there. What are you really trying to
do?

Cheers.

Tim.


More information about the llvm-dev mailing list