1

I am currently doing a static analysis on c code with llvm(via LLVM IR). I first transform the c code into .ll file, then I am parsing it with LLVM-Framework. The IR that I'm using is in SSA-form, so every result of an instruction is distinctive. But the problem is, I can't get the name of the result or the name of the operand if it only has a numeric name.(e.g. %1, %2 ,...). I tried below code to get the name,

Instruction & inst = *inst_it;
std::string name = inst.getOperand(0)->getName().str();

The variable 'name' will have a valid string value if the name is like [%sum.175.unr], but for names like %1, %2, .. above code only returns an empty string.

Example .ll file,

%5 = mul nsw i64 %indvars.iv84, %0
%6 = add nsw i64 %1, %indvars.iv84

Trying to get the name of %5, or %0, will give me an empty string, but with indvars.iv84, I will get a correct result. Reading the documentation didn't help much finding the problem. What should be the problem in this case?

izazu
  • 87
  • 9
  • 1
    Possible duplicate of [In LLVM IR, how can I print the name of a unnamed value which is represented as an unsigned numeric value with their prefix such as %2?](http://stackoverflow.com/questions/30732839/in-llvm-ir-how-can-i-print-the-name-of-a-unnamed-value-which-is-represented-as) – Ismail Badawi Dec 01 '15 at 22:45

0 Answers0