Bullet proof against undefined args produced by upgrading ols-style debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Laskey 2006-03-26 22:46:27 +00:00
parent 98e0410f07
commit fbcf23c3c1
2 changed files with 8 additions and 7 deletions

View File

@ -1114,7 +1114,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
case Intrinsic::dbg_stoppoint: { case Intrinsic::dbg_stoppoint: {
MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo(); MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
DbgStopPointInst &SPI = cast<DbgStopPointInst>(I); DbgStopPointInst &SPI = cast<DbgStopPointInst>(I);
if (DebugInfo && DebugInfo->Verify(SPI.getContext())) { if (DebugInfo && SPI.getContext() && DebugInfo->Verify(SPI.getContext())) {
std::vector<SDOperand> Ops; std::vector<SDOperand> Ops;
Ops.push_back(getRoot()); Ops.push_back(getRoot());
@ -1136,7 +1136,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
case Intrinsic::dbg_region_start: { case Intrinsic::dbg_region_start: {
MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo(); MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
DbgRegionStartInst &RSI = cast<DbgRegionStartInst>(I); DbgRegionStartInst &RSI = cast<DbgRegionStartInst>(I);
if (DebugInfo && DebugInfo->Verify(RSI.getContext())) { if (DebugInfo && RSI.getContext() && DebugInfo->Verify(RSI.getContext())) {
std::vector<SDOperand> Ops; std::vector<SDOperand> Ops;
unsigned LabelID = DebugInfo->RecordRegionStart(RSI.getContext()); unsigned LabelID = DebugInfo->RecordRegionStart(RSI.getContext());
@ -1152,7 +1152,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
case Intrinsic::dbg_region_end: { case Intrinsic::dbg_region_end: {
MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo(); MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
DbgRegionEndInst &REI = cast<DbgRegionEndInst>(I); DbgRegionEndInst &REI = cast<DbgRegionEndInst>(I);
if (DebugInfo && DebugInfo->Verify(REI.getContext())) { if (DebugInfo && REI.getContext() && DebugInfo->Verify(REI.getContext())) {
std::vector<SDOperand> Ops; std::vector<SDOperand> Ops;
unsigned LabelID = DebugInfo->RecordRegionEnd(REI.getContext()); unsigned LabelID = DebugInfo->RecordRegionEnd(REI.getContext());
@ -1168,7 +1168,8 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
case Intrinsic::dbg_func_start: { case Intrinsic::dbg_func_start: {
MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo(); MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
DbgFuncStartInst &FSI = cast<DbgFuncStartInst>(I); DbgFuncStartInst &FSI = cast<DbgFuncStartInst>(I);
if (DebugInfo && DebugInfo->Verify(FSI.getSubprogram())) { if (DebugInfo && FSI.getSubprogram() &&
DebugInfo->Verify(FSI.getSubprogram())) {
std::vector<SDOperand> Ops; std::vector<SDOperand> Ops;
unsigned LabelID = DebugInfo->RecordRegionStart(FSI.getSubprogram()); unsigned LabelID = DebugInfo->RecordRegionStart(FSI.getSubprogram());

View File

@ -45,13 +45,13 @@ static Value *CastOperand(Value *C) {
Value *DbgInfoIntrinsic::StripCast(Value *C) { Value *DbgInfoIntrinsic::StripCast(Value *C) {
if (Value *CO = CastOperand(C)) { if (Value *CO = CastOperand(C)) {
return StripCast(CO); C = StripCast(CO);
} else if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) { } else if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
if (GV->hasInitializer()) if (GV->hasInitializer())
if (Value *CO = CastOperand(GV->getInitializer())) if (Value *CO = CastOperand(GV->getInitializer()))
return StripCast(CO); C = StripCast(CO);
} }
return C; return dyn_cast<GlobalVariable>(C);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//