1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

Right now, Debugging information to encode scopes (DW_TAG_lexical_block) relies on DBG_LABEL. Unfortunately this intefers with the quality of optimized code.

This patch updates dwarf writer to encode scoping information in DWARF only in FastISel mode.

llvm-svn: 68973
This commit is contained in:
Devang Patel 2009-04-13 18:13:16 +00:00
parent ad7f61c279
commit 92d79ef835
4 changed files with 25 additions and 22 deletions

View File

@ -77,7 +77,7 @@ public:
void EndFunction(MachineFunction *MF); void EndFunction(MachineFunction *MF);
/// ValidDebugInfo - Return true if V represents valid debug info value. /// ValidDebugInfo - Return true if V represents valid debug info value.
bool ValidDebugInfo(Value *V); bool ValidDebugInfo(Value *V, bool FastISel);
/// RecordSourceLine - Register a source line with debug info. Returns a /// RecordSourceLine - Register a source line with debug info. Returns a
/// unique label ID used to generate a label and provide correspondence to /// unique label ID used to generate a label and provide correspondence to

View File

@ -3296,7 +3296,7 @@ public:
} }
/// ValidDebugInfo - Return true if V represents valid debug info value. /// ValidDebugInfo - Return true if V represents valid debug info value.
bool ValidDebugInfo(Value *V) { bool ValidDebugInfo(Value *V, bool FastISel) {
if (!V) if (!V)
return false; return false;
@ -3335,6 +3335,11 @@ public:
case DW_TAG_subprogram: case DW_TAG_subprogram:
assert(DISubprogram(GV).Verify() && "Invalid DebugInfo value"); assert(DISubprogram(GV).Verify() && "Invalid DebugInfo value");
break; break;
case DW_TAG_lexical_block:
/// FIXME. This interfers with the qualitfy of generated code when
/// during optimization.
if (FastISel == false)
return false;
default: default:
break; break;
} }
@ -4621,8 +4626,8 @@ void DwarfWriter::EndFunction(MachineFunction *MF) {
} }
/// ValidDebugInfo - Return true if V represents valid debug info value. /// ValidDebugInfo - Return true if V represents valid debug info value.
bool DwarfWriter::ValidDebugInfo(Value *V) { bool DwarfWriter::ValidDebugInfo(Value *V, bool FastISel) {
return DD && DD->ValidDebugInfo(V); return DD && DD->ValidDebugInfo(V, FastISel);
} }
/// RecordSourceLine - Records location information and associates it with a /// RecordSourceLine - Records location information and associates it with a

View File

@ -326,7 +326,7 @@ bool FastISel::SelectCall(User *I) {
default: break; default: break;
case Intrinsic::dbg_stoppoint: { case Intrinsic::dbg_stoppoint: {
DbgStopPointInst *SPI = cast<DbgStopPointInst>(I); DbgStopPointInst *SPI = cast<DbgStopPointInst>(I);
if (DW && DW->ValidDebugInfo(SPI->getContext())) { if (DW && DW->ValidDebugInfo(SPI->getContext(), true)) {
DICompileUnit CU(cast<GlobalVariable>(SPI->getContext())); DICompileUnit CU(cast<GlobalVariable>(SPI->getContext()));
std::string Dir, FN; std::string Dir, FN;
unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir), unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir),
@ -343,7 +343,7 @@ bool FastISel::SelectCall(User *I) {
} }
case Intrinsic::dbg_region_start: { case Intrinsic::dbg_region_start: {
DbgRegionStartInst *RSI = cast<DbgRegionStartInst>(I); DbgRegionStartInst *RSI = cast<DbgRegionStartInst>(I);
if (DW && DW->ValidDebugInfo(RSI->getContext())) { if (DW && DW->ValidDebugInfo(RSI->getContext(), true)) {
unsigned ID = unsigned ID =
DW->RecordRegionStart(cast<GlobalVariable>(RSI->getContext())); DW->RecordRegionStart(cast<GlobalVariable>(RSI->getContext()));
const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
@ -353,7 +353,7 @@ bool FastISel::SelectCall(User *I) {
} }
case Intrinsic::dbg_region_end: { case Intrinsic::dbg_region_end: {
DbgRegionEndInst *REI = cast<DbgRegionEndInst>(I); DbgRegionEndInst *REI = cast<DbgRegionEndInst>(I);
if (DW && DW->ValidDebugInfo(REI->getContext())) { if (DW && DW->ValidDebugInfo(REI->getContext(), true)) {
unsigned ID = unsigned ID =
DW->RecordRegionEnd(cast<GlobalVariable>(REI->getContext())); DW->RecordRegionEnd(cast<GlobalVariable>(REI->getContext()));
const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
@ -366,7 +366,7 @@ bool FastISel::SelectCall(User *I) {
DbgFuncStartInst *FSI = cast<DbgFuncStartInst>(I); DbgFuncStartInst *FSI = cast<DbgFuncStartInst>(I);
Value *SP = FSI->getSubprogram(); Value *SP = FSI->getSubprogram();
if (DW->ValidDebugInfo(SP)) { if (DW->ValidDebugInfo(SP, true)) {
// llvm.dbg.func.start implicitly defines a dbg_stoppoint which is what // llvm.dbg.func.start implicitly defines a dbg_stoppoint which is what
// (most?) gdb expects. // (most?) gdb expects.
DISubprogram Subprogram(cast<GlobalVariable>(SP)); DISubprogram Subprogram(cast<GlobalVariable>(SP));
@ -401,7 +401,7 @@ bool FastISel::SelectCall(User *I) {
case Intrinsic::dbg_declare: { case Intrinsic::dbg_declare: {
DbgDeclareInst *DI = cast<DbgDeclareInst>(I); DbgDeclareInst *DI = cast<DbgDeclareInst>(I);
Value *Variable = DI->getVariable(); Value *Variable = DI->getVariable();
if (DW && DW->ValidDebugInfo(Variable)) { if (DW && DW->ValidDebugInfo(Variable, true)) {
// Determine the address of the declared object. // Determine the address of the declared object.
Value *Address = DI->getAddress(); Value *Address = DI->getAddress();
if (BitCastInst *BCI = dyn_cast<BitCastInst>(Address)) if (BitCastInst *BCI = dyn_cast<BitCastInst>(Address))

View File

@ -332,7 +332,7 @@ void FunctionLoweringInfo::set(Function &fn, MachineFunction &mf,
DwarfWriter *DW = DAG.getDwarfWriter(); DwarfWriter *DW = DAG.getDwarfWriter();
DbgStopPointInst *SPI = cast<DbgStopPointInst>(I); DbgStopPointInst *SPI = cast<DbgStopPointInst>(I);
if (DW && DW->ValidDebugInfo(SPI->getContext())) { if (DW && DW->ValidDebugInfo(SPI->getContext(), false)) {
DICompileUnit CU(cast<GlobalVariable>(SPI->getContext())); DICompileUnit CU(cast<GlobalVariable>(SPI->getContext()));
std::string Dir, FN; std::string Dir, FN;
unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir), unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir),
@ -351,7 +351,7 @@ void FunctionLoweringInfo::set(Function &fn, MachineFunction &mf,
DbgFuncStartInst *FSI = cast<DbgFuncStartInst>(I); DbgFuncStartInst *FSI = cast<DbgFuncStartInst>(I);
Value *SP = FSI->getSubprogram(); Value *SP = FSI->getSubprogram();
if (DW->ValidDebugInfo(SP)) { if (DW->ValidDebugInfo(SP, false)) {
DISubprogram Subprogram(cast<GlobalVariable>(SP)); DISubprogram Subprogram(cast<GlobalVariable>(SP));
DICompileUnit CU(Subprogram.getCompileUnit()); DICompileUnit CU(Subprogram.getCompileUnit());
std::string Dir, FN; std::string Dir, FN;
@ -3921,7 +3921,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
case Intrinsic::dbg_stoppoint: { case Intrinsic::dbg_stoppoint: {
DwarfWriter *DW = DAG.getDwarfWriter(); DwarfWriter *DW = DAG.getDwarfWriter();
DbgStopPointInst &SPI = cast<DbgStopPointInst>(I); DbgStopPointInst &SPI = cast<DbgStopPointInst>(I);
if (DW && DW->ValidDebugInfo(SPI.getContext())) { if (DW && DW->ValidDebugInfo(SPI.getContext(), Fast)) {
MachineFunction &MF = DAG.getMachineFunction(); MachineFunction &MF = DAG.getMachineFunction();
if (Fast) if (Fast)
DAG.setRoot(DAG.getDbgStopPoint(getRoot(), DAG.setRoot(DAG.getDbgStopPoint(getRoot(),
@ -3941,12 +3941,11 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
case Intrinsic::dbg_region_start: { case Intrinsic::dbg_region_start: {
DwarfWriter *DW = DAG.getDwarfWriter(); DwarfWriter *DW = DAG.getDwarfWriter();
DbgRegionStartInst &RSI = cast<DbgRegionStartInst>(I); DbgRegionStartInst &RSI = cast<DbgRegionStartInst>(I);
if (DW && DW->ValidDebugInfo(RSI.getContext())) { if (DW && DW->ValidDebugInfo(RSI.getContext(), Fast)) {
unsigned LabelID = unsigned LabelID =
DW->RecordRegionStart(cast<GlobalVariable>(RSI.getContext())); DW->RecordRegionStart(cast<GlobalVariable>(RSI.getContext()));
if (Fast) DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(), getRoot(), LabelID));
getRoot(), LabelID));
} }
return 0; return 0;
@ -3954,7 +3953,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
case Intrinsic::dbg_region_end: { case Intrinsic::dbg_region_end: {
DwarfWriter *DW = DAG.getDwarfWriter(); DwarfWriter *DW = DAG.getDwarfWriter();
DbgRegionEndInst &REI = cast<DbgRegionEndInst>(I); DbgRegionEndInst &REI = cast<DbgRegionEndInst>(I);
if (DW && DW->ValidDebugInfo(REI.getContext())) { if (DW && DW->ValidDebugInfo(REI.getContext(), Fast)) {
MachineFunction &MF = DAG.getMachineFunction(); MachineFunction &MF = DAG.getMachineFunction();
DISubprogram Subprogram(cast<GlobalVariable>(REI.getContext())); DISubprogram Subprogram(cast<GlobalVariable>(REI.getContext()));
@ -3969,9 +3968,8 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
unsigned LabelID = unsigned LabelID =
DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext())); DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext()));
if (Fast) DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(), getRoot(), LabelID));
getRoot(), LabelID));
} }
return 0; return 0;
@ -3981,7 +3979,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
if (!DW) return 0; if (!DW) return 0;
DbgFuncStartInst &FSI = cast<DbgFuncStartInst>(I); DbgFuncStartInst &FSI = cast<DbgFuncStartInst>(I);
Value *SP = FSI.getSubprogram(); Value *SP = FSI.getSubprogram();
if (SP && DW->ValidDebugInfo(SP)) { if (SP && DW->ValidDebugInfo(SP, Fast)) {
// llvm.dbg.func.start implicitly defines a dbg_stoppoint which is // llvm.dbg.func.start implicitly defines a dbg_stoppoint which is
// what (most?) gdb expects. // what (most?) gdb expects.
MachineFunction &MF = DAG.getMachineFunction(); MachineFunction &MF = DAG.getMachineFunction();
@ -4023,7 +4021,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
DwarfWriter *DW = DAG.getDwarfWriter(); DwarfWriter *DW = DAG.getDwarfWriter();
DbgDeclareInst &DI = cast<DbgDeclareInst>(I); DbgDeclareInst &DI = cast<DbgDeclareInst>(I);
Value *Variable = DI.getVariable(); Value *Variable = DI.getVariable();
if (DW && DW->ValidDebugInfo(Variable)) if (DW && DW->ValidDebugInfo(Variable, Fast))
DAG.setRoot(DAG.getNode(ISD::DECLARE, dl, MVT::Other, getRoot(), DAG.setRoot(DAG.getNode(ISD::DECLARE, dl, MVT::Other, getRoot(),
getValue(DI.getAddress()), getValue(Variable))); getValue(DI.getAddress()), getValue(Variable)));
} else { } else {