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

John Criswell criswell at illinois.edu
Fri Feb 25 13:36:37 PST 2011


On 2/25/11 1:50 PM, Kodakara, Sreekumar V wrote:
> 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?

The problem occurs because the value doesn't actually have a name; the 
LLVM disassembler is just printing %13 because the value has no name.

You can run the -instnamer pass right before your analysis/transform 
pass.  It will give each instruction a real name.

-- John T.

> Thanks
> Sreekumar
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list