Kodakara, Sreekumar V
2011-Feb-25 19:50 UTC
[LLVMdev] Accessing the name of the temporary variable in Instruction
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
John Criswell
2011-Feb-25 21:36 UTC
[LLVMdev] Accessing the name of the temporary variable in Instruction
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
Kodakara, Sreekumar V
2011-Feb-25 23:03 UTC
[LLVMdev] Accessing the name of the temporary variable in Instruction
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. The -instnamer pass was the one that I wanted to solve the problem. Thanks for the information John. Sreekumar
Possibly Parallel Threads
- [LLVMdev] Accessing the name of the temporary variable in Instruction
- [LLVMdev] Filename in dynamically loaded function pass
- [LLVMdev] Filename in dynamically loaded function pass
- [LLVMdev] llc is taking a long time at -O1 to convert *.bc to *.s
- [LLVMdev] Break operands into multiple instructions