Handle new forms of llvm.dbg intrinsics.
authorJim Laskey <jlaskey@mac.com>
Thu, 23 Mar 2006 18:06:46 +0000 (18:06 +0000)
committerJim Laskey <jlaskey@mac.com>
Thu, 23 Mar 2006 18:06:46 +0000 (18:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26988 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/IntrinsicLowering.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
lib/Debugger/ProgramInfo.cpp

index 316d1ad2f64b189ed4255e803be9d7f2266b8509..515752e6b709c63f5e47226cd34605bceb70050f 100644 (file)
@@ -403,6 +403,7 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
   case Intrinsic::dbg_region_start:
   case Intrinsic::dbg_region_end:
   case Intrinsic::dbg_func_start:
+  case Intrinsic::dbg_declare:
     break;    // Simply strip out debugging intrinsics
 
   case Intrinsic::memcpy_i32:
index 80c842de5e96227f9247e6be8c9838dd61735368..b579ebf837aa32fc0717306fdba2f4c1010297ad 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/InlineAsm.h"
 #include "llvm/Instructions.h"
 #include "llvm/Intrinsics.h"
+#include "llvm/IntrinsicInst.h"
 #include "llvm/CodeGen/IntrinsicLowering.h"
 #include "llvm/CodeGen/MachineDebugInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
@@ -1032,44 +1033,88 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
     
   case Intrinsic::dbg_stoppoint: {
     MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
-    if (DebugInfo &&  DebugInfo->Verify(I.getOperand(3))) {
+    DbgStopPointInst &SPI = cast<DbgStopPointInst>(I);
+    if (DebugInfo &&  DebugInfo->Verify(SPI.getContext())) {
       std::vector<SDOperand> Ops;
 
-      // Input Chain
       Ops.push_back(getRoot());
-      
-      // line number
-      Ops.push_back(getValue(I.getOperand(1)));
-     
-      // column
-      Ops.push_back(getValue(I.getOperand(2)));
+      Ops.push_back(getValue(SPI.getLineValue()));
+      Ops.push_back(getValue(SPI.getColumnValue()));
 
-      DebugInfoDesc *DD = DebugInfo->getDescFor(I.getOperand(3));
+      DebugInfoDesc *DD = DebugInfo->getDescFor(SPI.getContext());
       assert(DD && "Not a debug information descriptor");
-      CompileUnitDesc *CompileUnit = dyn_cast<CompileUnitDesc>(DD);
-      assert(CompileUnit && "Not a compile unit");
+      CompileUnitDesc *CompileUnit = cast<CompileUnitDesc>(DD);
+      
       Ops.push_back(DAG.getString(CompileUnit->getFileName()));
       Ops.push_back(DAG.getString(CompileUnit->getDirectory()));
       
-      if (Ops.size() == 5)  // Found filename/workingdir.
-        DAG.setRoot(DAG.getNode(ISD::LOCATION, MVT::Other, Ops));
+      DAG.setRoot(DAG.getNode(ISD::LOCATION, MVT::Other, Ops));
     }
-    
-    setValue(&I, DAG.getNode(ISD::UNDEF, TLI.getValueType(I.getType())));
+
     return 0;
   }
-  case Intrinsic::dbg_region_start:
-    if (I.getType() != Type::VoidTy)
-      setValue(&I, DAG.getNode(ISD::UNDEF, TLI.getValueType(I.getType())));
+  case Intrinsic::dbg_region_start: {
+    MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
+    DbgRegionStartInst &RSI = cast<DbgRegionStartInst>(I);
+    if (DebugInfo && DebugInfo->Verify(RSI.getContext())) {
+      std::vector<SDOperand> Ops;
+
+      unsigned LabelID = DebugInfo->RecordRegionStart(RSI.getContext());
+      
+      Ops.push_back(getRoot());
+      Ops.push_back(DAG.getConstant(LabelID, MVT::i32));
+
+      DAG.setRoot(DAG.getNode(ISD::DEBUG_LABEL, MVT::Other, Ops));
+    }
+
     return 0;
-  case Intrinsic::dbg_region_end:
-    if (I.getType() != Type::VoidTy)
-      setValue(&I, DAG.getNode(ISD::UNDEF, TLI.getValueType(I.getType())));
+  }
+  case Intrinsic::dbg_region_end: {
+    MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
+    DbgRegionEndInst &REI = cast<DbgRegionEndInst>(I);
+    if (DebugInfo && DebugInfo->Verify(REI.getContext())) {
+      std::vector<SDOperand> Ops;
+
+      unsigned LabelID = DebugInfo->RecordRegionEnd(REI.getContext());
+      
+      Ops.push_back(getRoot());
+      Ops.push_back(DAG.getConstant(LabelID, MVT::i32));
+
+      DAG.setRoot(DAG.getNode(ISD::DEBUG_LABEL, MVT::Other, Ops));
+    }
+
     return 0;
-  case Intrinsic::dbg_func_start:
-    if (I.getType() != Type::VoidTy)
-      setValue(&I, DAG.getNode(ISD::UNDEF, TLI.getValueType(I.getType())));
+  }
+  case Intrinsic::dbg_func_start: {
+    MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
+    DbgFuncStartInst &FSI = cast<DbgFuncStartInst>(I);
+    if (DebugInfo && DebugInfo->Verify(FSI.getSubprogram())) {
+      std::vector<SDOperand> Ops;
+
+      unsigned LabelID = DebugInfo->RecordRegionStart(FSI.getSubprogram());
+      
+      Ops.push_back(getRoot());
+      Ops.push_back(DAG.getConstant(LabelID, MVT::i32));
+
+      DAG.setRoot(DAG.getNode(ISD::DEBUG_LABEL, MVT::Other, Ops));
+    }
+
     return 0;
+  }
+  case Intrinsic::dbg_declare: {
+    MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
+    DbgDeclareInst &DI = cast<DbgDeclareInst>(I);
+    if (DebugInfo && DebugInfo->Verify(DI.getVariable())) {
+      std::vector<SDOperand> Ops;
+
+      SDOperand AllocaOp  = getValue(I.getOperand(1));
+      if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(AllocaOp)) {
+        DebugInfo->RecordVariable(DI.getVariable(), FI->getIndex());
+      }
+    }
+
+    return 0;
+  }
     
   case Intrinsic::isunordered_f32:
   case Intrinsic::isunordered_f64:
index 9ed0db2f12d30bf04a3aa26a2a8d86b4da9ac12c..3bbb0ec9362275656e20239020ddac32a2797b4e 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Intrinsics.h"
+#include "llvm/IntrinsicInst.h"
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
 #include "llvm/Debugger/SourceFile.h"
@@ -57,17 +58,15 @@ static const GlobalVariable *getNextStopPoint(const Value *V, unsigned &LineNo,
       // Infinite loops == bad, ignore PHI nodes.
       ShouldRecurse = false;
     } else if (const CallInst *CI = dyn_cast<CallInst>(*UI)) {
+      
       // If we found a stop point, check to see if it is earlier than what we
       // already have.  If so, remember it.
       if (const Function *F = CI->getCalledFunction())
-        if (F->getIntrinsicID() == Intrinsic::dbg_stoppoint) {
-          unsigned CurLineNo = ~0, CurColNo = ~0;
+        if (const DbgStopPointInst *SPI = dyn_cast<DbgStopPointInst>(CI)) {
+          unsigned CurLineNo = SPI->getLine();
+          unsigned CurColNo = SPI->getColumn();
           const GlobalVariable *CurDesc = 0;
-          if (const ConstantInt *C = dyn_cast<ConstantInt>(CI->getOperand(1)))
-            CurLineNo = C->getRawValue();
-          if (const ConstantInt *C = dyn_cast<ConstantInt>(CI->getOperand(2)))
-            CurColNo = C->getRawValue();
-          const Value *Op = CI->getOperand(3);
+          const Value *Op = SPI->getContext();
 
           if ((CurDesc = dyn_cast<GlobalVariable>(Op)) &&
               (LineNo < LastLineNo ||
@@ -78,7 +77,6 @@ static const GlobalVariable *getNextStopPoint(const Value *V, unsigned &LineNo,
           }
           ShouldRecurse = false;
         }
-
     }
 
     // If this is not a phi node or a stopping point, recursively scan the users