Added/removed header file
[oota-llvm.git] / lib / CodeGen / MachineInstrAnnot.cpp
index 27cf7ad931ce76880fe0abd109c32c5bf7e017b5..419e10ecd31bd52a44b290b895c13e8cf177f6b3 100644 (file)
@@ -7,13 +7,12 @@
 
 #include "llvm/CodeGen/MachineInstrAnnot.h"
 #include "llvm/CodeGen/InstrSelection.h"
-#include "llvm/CodeGen/InstrSelectionSupport.h"
 #include "llvm/CodeGen/MachineCodeForInstruction.h"
 #include "llvm/iOther.h"
 #include "llvm/Type.h"
 
 
-CallArgsDescriptor::CallArgsDescriptor(const CallInst* _callInstr,
+CallArgsDescriptor::CallArgsDescriptor(CallInst* _callInstr,
                                        TmpInstruction* _retAddrReg,
                                        bool _isVarArgs, bool _noPrototype)
   : callInstr(_callInstr),
@@ -36,7 +35,7 @@ CallArgsDescriptor::CallArgsDescriptor(const CallInst* _callInstr,
 }
 
 
-const CallInst*
+CallInst*
 CallArgsDescriptor::getReturnValue() const
 {
   return (callInstr->getType() == Type::VoidTy? NULL : callInstr);
@@ -45,18 +44,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<TmpInstruction>(MI->getImplicitRef(MI->getNumImplicitRefs()-1));
+    cast<TmpInstruction>(isa<Function>(MI->getOperand(0).getVRegValue())
+                         ? MI->getImplicitRef(MI->getNumImplicitRefs()-1)
+                         : MI->getOperand(2).getVRegValue());
+
   assert(retAddrReg->getNumOperands() == 1 &&
          isa<CallInst>(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<CallInst>(retAddrReg->getOperand(0));
 
   CallArgsDescriptor* desc =