Get Name of numbered variables

You can get the name of a variable by using the method getName() of llvm::Value. However it returns a blank string if the variable is a numbered variable, such as %11. How can I make it return %11 in such case.

Hello,

You can get the name of a variable by using the method getName() of
llvm::Value. However it returns a blank string if the variable is a
numbered variable, such as %11. How can I make it return %11 in such
case.

I'd like to second this question. Looking at the source, the numbered
vars are just checked for being sequential and dropped. Well, that may
be understood given sequentiality constraint (what if other
instructions inserted inbetween later), but is there other
human-readable unique identifier for each instruction?

More generally, is it possible to get parsed, but linear
LLVM IR (corresponding to LLVM assembly)? - otherwise it seems DAG is
constructed straight on IR load.

The numbers come from SlotTracker in AsmWriter.cpp. They are basically generated when the IR needs to be printed in the human readable form, and don't necessarily exist otherwise. They may also change over time, as the IR changes (i.e. the same value may get a different number next time).

-Krzysztof

The numbers are not explicitly stored in the in-memory representation.
Their only purpose is to name the variable in the textual
representation (I believe the bitcode representation uses a different
scheme based on relative numbering). The numbers are created during
serialization; see SlotTracker::getLocalSlot() in
lib/IR/AsmWriter.cpp.

Also related: <http://llvm.org/docs/FAQ.html#what-api-do-i-use-to-store-a-value-to-one-of-the-virtual-registers-in-llvm-ir-s-ssa-representation&gt;\.

-- Sean Silva