Get identifier for unnamed temporary

Is there a way through the Value class to get the identifier for an
unnamed temporary? Or alternatively, could someone point me to the
code where temporaries are assigned sequential numbers as identifiers
so I can better understand this issue?


hi Scott,

VMCore will auto-unique value names for you. Most passes just create all instructions with a name like "tmp" and let VMCore unique them. Is this enough for you?


The relevant code is llvm/lib/VMCore/AsmWriter.cpp. That said, you
shouldn't really need them anywhere; what are you trying to do?


I am adding some instrumentation that requires me to track information
associated with llvm values. I need a good way to identify these
values by passing a unique id (can be unique within function scope) to
the instrumenting function. Let me be more clear with an example.

If I have

%3 = add i32 %1, %2

then I would like to insert a function call that will somehow log that
%3 requires %1 and %2 to be computed at this step. So my original plan
was to have my pass create a mapping of identifiers to numerical
constants, and then to pass the appropriate constants to the
instrumenting function at runtime.

Is there a better approach?


Just ignore the identifiers, and construct your own instruction
numbering by iterating over the function.


If your pass were to map "Instruction*" to a vector of "Value*"s, then
that might work. LLVM's IR is in SSA form, so that information is
pretty much already available by just looking at the Instruction's