--- Merging (from foreign repository) r64714 into '.':

U    include/llvm/CodeGen/DebugLoc.h
U    lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
U    lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
U    lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp

Enable debug location generation at -Os. This goes with the reapplication of the
r63639 patch.

llvm-svn: 64715
This commit is contained in:
Bill Wendling 2009-02-17 01:04:54 +00:00
parent 01c3d23814
commit 3c50922ea0
4 changed files with 61 additions and 36 deletions

View File

@ -37,17 +37,14 @@ namespace llvm {
public:
DebugLoc() : Idx(~0U) {} // Defaults to invalid.
static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = 0; return L; }
static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = ~0U; return L; }
static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
unsigned getIndex() const { return Idx; }
/// isInvalid - Return true if the DebugLoc is invalid.
bool isInvalid() const { return Idx == ~0U; }
/// isUnknown - Return true if there is no debug info for the SDNode /
/// MachineInstr.
bool isUnknown() const { return Idx == 0; }
bool isUnknown() const { return Idx == ~0U; }
bool operator==(const DebugLoc &DL) const { return Idx == DL.Idx; }
bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }

View File

@ -28,6 +28,7 @@
#include "llvm/CallingConv.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
@ -1290,8 +1291,11 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) {
unsigned Line = DSP->getLine();
unsigned Col = DSP->getColumn();
// A bit self-referential to have DebugLoc on Debug_Loc nodes, but
// it won't hurt anything.
const Function *F = DAG.getMachineFunction().getFunction();
if (!F->hasFnAttr(Attribute::OptimizeForSize)) {
// A bit self-referential to have DebugLoc on Debug_Loc nodes, but it
// won't hurt anything.
if (useDEBUG_LOC) {
SDValue Ops[] = { Tmp1, DAG.getConstant(Line, MVT::i32),
DAG.getConstant(Col, MVT::i32),
@ -1304,6 +1308,9 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) {
} else {
Result = Tmp1; // chain
}
} else {
Result = Tmp1; // chain
}
break;
}
case TargetLowering::Legal: {

View File

@ -3915,6 +3915,10 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
if (DW && DW->ValidDebugInfo(RSI.getContext())) {
unsigned LabelID =
DW->RecordRegionStart(cast<GlobalVariable>(RSI.getContext()));
const Function *F = I.getParent()->getParent();
// FIXME: Support more than just -Os.
if (!F->hasFnAttr(Attribute::OptimizeForSize))
DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
getRoot(), LabelID));
}
@ -3927,6 +3931,10 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
if (DW && DW->ValidDebugInfo(REI.getContext())) {
unsigned LabelID =
DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext()));
const Function *F = I.getParent()->getParent();
// FIXME: Support more than just -Os.
if (!F->hasFnAttr(Attribute::OptimizeForSize))
DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
getRoot(), LabelID));
}
@ -3950,11 +3958,15 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
// function start. It will be emitted at asm emission time. However,
// create a label if this is a beginning of inlined function.
unsigned Line = Subprogram.getLineNumber();
unsigned LabelID = DW->RecordSourceLine(Line, 0, SrcFile);
// FIXME: Support more than just -Os.
const Function *F = I.getParent()->getParent();
if (!F->hasFnAttr(Attribute::OptimizeForSize)) {
unsigned LabelID = DW->RecordSourceLine(Line, 0, SrcFile);
if (DW->getRecordSourceLineCount() != 1)
DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
getRoot(), LabelID));
}
setCurDebugLoc(DebugLoc::get(DAG.getMachineFunction().
getOrCreateDebugLocID(SrcFile, Line, 0)));
@ -3963,15 +3975,19 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
return 0;
}
case Intrinsic::dbg_declare: {
const Function *F = I.getParent()->getParent();
if (!F->hasFnAttr(Attribute::OptimizeForSize)) {
DwarfWriter *DW = DAG.getDwarfWriter();
DbgDeclareInst &DI = cast<DbgDeclareInst>(I);
Value *Variable = DI.getVariable();
if (DW && DW->ValidDebugInfo(Variable))
DAG.setRoot(DAG.getNode(ISD::DECLARE, dl, MVT::Other, getRoot(),
getValue(DI.getAddress()), getValue(Variable)));
} else {
// FIXME: Do something sensible here when we support debug declare.
}
return 0;
}
case Intrinsic::eh_exception: {
if (!CurMBB->isLandingPad()) {
// FIXME: Mark exception register as live in. Hack for PR1508.

View File

@ -726,16 +726,21 @@ void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
if (TAI->doesSupportDebugInformation()) {
const Function *F = MF->getFunction();
// FIXME: Support more than '-Os'.
if (F->hasFnAttr(Attribute::OptimizeForSize)) {
static DebugLoc PrevDL = DebugLoc::getUnknownLoc();
DebugLoc CurDL = MI->getDebugLoc();
if (!CurDL.isInvalid() && !CurDL.isUnknown() && PrevDL != CurDL) {
if (!CurDL.isUnknown() && PrevDL != CurDL) {
DebugLocTuple DLT = MF->getDebugLocTuple(CurDL);
printLabel(DW->RecordSourceLine(DLT.Line, DLT.Col, DLT.Src));
}
PrevDL = CurDL;
}
}
// Call the autogenerated instruction printer routines.
printInstruction(MI);