mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Handle new forms of llvm.dbg intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26988 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4556ce5d11
commit
43970fec32
@ -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:
|
||||
|
@ -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());
|
||||
Ops.push_back(getValue(SPI.getLineValue()));
|
||||
Ops.push_back(getValue(SPI.getColumnValue()));
|
||||
|
||||
// line number
|
||||
Ops.push_back(getValue(I.getOperand(1)));
|
||||
|
||||
// column
|
||||
Ops.push_back(getValue(I.getOperand(2)));
|
||||
|
||||
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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user