[llvm-dev] Arguments name IR LLVM

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 29 05:05:34 PDT 2019


(Adding llvm-dev back to reply list).

On Mon, 29 Jul 2019 at 12:52, mohamed messelka <m14m at live.fr> wrote:
> I want to generate DFG with names because later I need them,  so how to get the names from call function  :

Normally any graph structure you build up would be constructed
directly from the "Value *" pointers rather than by trying to
cross-reference names of Values. You say you need them later, but what
for?

>  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)
>
> any idea?

Something like this would work:

    std::string CurName;
    unsigned ValueNo = 0;
    for (auto &Arg : F.args()) {
      CurName = Arg.getName();
      if (CurName.empty())
        CurName = std::to_string(ValueNo++);
      [... Use CurName ...]
    }

But please think really hard about why you're trying to do this.
Wanting to use names of LLVM instructions is a large red flag that
there's something wrong.

Cheers.

Tim.


More information about the llvm-dev mailing list