LLVM:help

Sir ,how can I get the variable %2 in instruction
%2 = sub nsw i32 1, %yIf I am using getName() function then it outputs the null string.
How can I get the original name?

Regards,
Rajwinder Singh

What would you need the name for? If you're using the C++ API you
just pass it as a Value* to the IRBuilder API.

Reid

RAJWINDER SINGH wrote:

Sir ,how can I get the variable %2 in instruction
%2 = sub nsw i32 1, %y If I am using getName() function then it outputs the null string.
How can I get the original name?

I don't believe the instruction has a name. The LLVM disassembler just assigns a numeric name when generating the .ll file so that the output is readable by a human.

What is it that you are trying to do that requires that name of an SSA value?

-- John T.

Hello Rajwinder,

When you are using numbered registers there is no name to get. Names are optional in LLVM.

–Sam

RAJWINDER SINGH wrote:

I am making a CDFG graph out of the instruction.

What is a CDFG? Do you mean a control dependence graph? Control-dependence can be computed utilizing the PostDominatorTree pass.

for that purpose I require the name because
if I am using its ID then ID may be same for the two such variables.

What do you mean by an instruction's ID?

How can I distinguish b/w them?

I'm assuming that you're writing an LLVM analysis pass that creates this CDFG data structure as an internal, in-memory data structure. If that is the case, then you simply use the pointer to the Instruction object to identify it. Each Instruction object inhabits a different location in memory; therefore, pointers to them are unique.

-- John T.