[LLVMdev] Figuring out the parameters of the Call Instruction

shankha shankhabanerjee at gmail.com
Thu Jul 15 10:27:53 PDT 2010


Hi Duncan,

Thanks for pointing out my mistake. I will reword my  questions.

//C code
int var1; //global

int a, b;
foo(a, b);
bar(c);
 generates following

//LLVM IR
%1 = load a;
%2 = load b;
call foo(%1, %2)
call bar(@var1)

CallInst.getOperand(1).getNameStr() on foo, returns null,
but on bar returns var1.

Similarly, for
call void @p_ptr(i64 ptrtoint (%struct.my_struct* @abc to i64))
nounwind, !dbg !31

CallInst.getOperand(1).getNameStr(),  return abc and type returns i64,
How do I figure the operand is a const expression and a cast operator
was used to generate it.

More generally, When I use Instruction iterator on BasicBlock, I get
the RHS of instruction
but not  the LHS. How do I get name of nameless LHS registers(%1, %2).

C Code :    p_ptr ((unsigned long) &abc);
LLVM IR : call void @p_ptr(i64 ptrtoint (%struct.my_struct* @abc to
i64)) nounwind, !dbg !52
I think by the call CI->getArgOperand(0) you mean CI->getOperand(0).
That doesn't return the ptrtoint constant expression. The CI instruction
has shows two operands.  The first operand is the function name. The
second operand
prints NULL.

thank you,
Shankha Banerjee



More information about the llvm-dev mailing list