From: Vikram S. Adve Date: Thu, 31 Oct 2002 15:34:48 +0000 (+0000) Subject: Restore support for indirect function calls (which briefly wasn't working X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=26fbcec43bd4e32f44849ea1bb2889eb9f5ed0f4;p=oota-llvm.git Restore support for indirect function calls (which briefly wasn't working after I removed annotations on MachineInstr for the CallDescriptor). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4469 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/MachineInstrAnnot.cpp b/lib/CodeGen/MachineInstrAnnot.cpp index 27cf7ad931c..8d7d4724f5b 100644 --- a/lib/CodeGen/MachineInstrAnnot.cpp +++ b/lib/CodeGen/MachineInstrAnnot.cpp @@ -45,18 +45,24 @@ CallArgsDescriptor::getReturnValue() const // Mechanism to get the descriptor for a CALL MachineInstr. // We get the LLVM CallInstr from the ret. addr. register argument -// of the CALL MachineInstr, then get the CallArgsDescriptor from the -// MachineCodeForInstruction object for the CallInstr. +// of the CALL MachineInstr (which is explicit operand #3 for indirect +// calls or the last implicit operand for direct calls). We then get +// the CallArgsDescriptor from the MachineCodeForInstruction object for +// the CallInstr. // This is roundabout but avoids adding a new map or annotation just // to keep track of CallArgsDescriptors. // CallArgsDescriptor *CallArgsDescriptor::get(const MachineInstr* MI) { const TmpInstruction* retAddrReg = - cast(MI->getImplicitRef(MI->getNumImplicitRefs()-1)); + cast(isa(MI->getOperand(0).getVRegValue()) + ? MI->getImplicitRef(MI->getNumImplicitRefs()-1) + : MI->getOperand(2).getVRegValue()); + assert(retAddrReg->getNumOperands() == 1 && isa(retAddrReg->getOperand(0)) && - "Order of implicit args of CALL instr. changed. FIX THIS CODE!"); + "Location of callInstr arg for CALL instr. changed? FIX THIS CODE!"); + const CallInst* callInstr = cast(retAddrReg->getOperand(0)); CallArgsDescriptor* desc =