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?