aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Laskey <jlaskey@mac.com>2006-03-23 18:06:46 +0000
committerJim Laskey <jlaskey@mac.com>2006-03-23 18:06:46 +0000
commit43970fec322d9e0153ca513de41d80af1c79bdde (patch)
treecc69019964f4248747b2d86cdf64b984ce8463ca
parent4556ce5d115f93ad6809d77810b9b770e5f737f2 (diff)
Handle new forms of llvm.dbg intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26988 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp1
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp93
-rw-r--r--lib/Debugger/ProgramInfo.cpp14
3 files changed, 76 insertions, 32 deletions
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index 316d1ad2f6..515752e6b7 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -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:
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 80c842de5e..b579ebf837 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -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:
diff --git a/lib/Debugger/ProgramInfo.cpp b/lib/Debugger/ProgramInfo.cpp
index 9ed0db2f12..3bbb0ec936 100644
--- a/lib/Debugger/ProgramInfo.cpp
+++ b/lib/Debugger/ProgramInfo.cpp
@@ -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