Hi, I was trying to use the following code in a if condition I->getOperand(0)->hasName() where I is an instruction with following condition already true - I->getOpcode() == Instruction::Call When I compiled a C code with llvm-2.9, I see a function call with no operand name (for operand 0) . This happens for a function with varArgs. The interesting part is that the same C code when compiled with llvm-2.6 contains the I->getOperand(0)->Name as name of the function. I will try to dig in to get the reason. Can some one give me pointer to what can be reason for this? Thanks and regards, Ankur
On Fri, Jul 1, 2011 at 12:35 AM, ankur deshwal <a.s.deshwal at gmail.com> wrote:> Hi, > > I was trying to use the following code in a if condition > I->getOperand(0)->hasName() > > where I is an instruction with following condition already true - > I->getOpcode() == Instruction::Call > > When I compiled a C code with llvm-2.9, I see a function call with no > operand name (for operand 0) . This happens for a function with > varArgs. The interesting part is that the same C code when compiled > with llvm-2.6 contains the I->getOperand(0)->Name as name of the > function. > > I will try to dig in to get the reason. Can some one give me pointer > to what can be reason for this?The order of the operands of a CallInst changed; try using something like "cast<CallInst>(I)->getCalledFunction()" instead. -Eli
Thanks Eli, It was stupid to miss that even with gdb :). Thanks again. Ankur On Fri, Jul 1, 2011 at 4:59 PM, Eli Friedman <eli.friedman at gmail.com> wrote:> On Fri, Jul 1, 2011 at 12:35 AM, ankur deshwal <a.s.deshwal at gmail.com> wrote: >> Hi, >> >> I was trying to use the following code in a if condition >> I->getOperand(0)->hasName() >> >> where I is an instruction with following condition already true - >> I->getOpcode() == Instruction::Call >> >> When I compiled a C code with llvm-2.9, I see a function call with no >> operand name (for operand 0) . This happens for a function with >> varArgs. The interesting part is that the same C code when compiled >> with llvm-2.6 contains the I->getOperand(0)->Name as name of the >> function. >> >> I will try to dig in to get the reason. Can some one give me pointer >> to what can be reason for this? > > The order of the operands of a CallInst changed; try using something > like "cast<CallInst>(I)->getCalledFunction()" instead. > > -Eli >