[LLVMdev] Accessing the name of the temporary variable in Instruction

Kodakara, Sreekumar V sreekumar.v.kodakara at intel.com
Fri Feb 25 11:50:59 PST 2011


I have developed a pass to instrument LLVM bit code files with calls to a custom instrumentation library. For one of the instrumentation calls, I need to pass the name of the temporary variable used in LLVM bit code. 

For example, if I see LLVM assembly code as shown below,

%13 = icmp eq i64 %11, 0, !dbg !14

After the instrumentation pass, it needs to look like the following

%13 = icmp eq i64 %11, 0, !dbg !14
call void @instrumentation_function(i8* getelementptr inbounds ([5 x i8]* @.str6, i64 0, i64 0))

where str6 is a private constant declared as follows
@.str6 = private constant [4 x i8] c"%13\00"

Note that the private constant that I am passing to the instrumentation_function is the name of the target temporary variable for the icmp instruction. I cannot find a way to get the name of the temporary variable used by the Instruction. In this case, I cannot find a way to get to %13 (or the number 13) from the Value/Instruction object holding this instruction. getName() does not return anything as %13 is not a variable declared in the program. Is there a way to get to this temporary variable name? 

Thanks
Sreekumar






More information about the llvm-dev mailing list