[llvm-commits] [llvm] r64714 - in /llvm/branches/Apple/Dib: include/llvm/CodeGen/DebugLoc.h lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
Bill Wendling
isanbard at gmail.com
Mon Feb 16 17:02:43 PST 2009
Author: void
Date: Mon Feb 16 19:02:43 2009
New Revision: 64714
URL: http://llvm.org/viewvc/llvm-project?rev=64714&view=rev
Log:
Enable debug location generation at -Os. This goes with the reapplication of the
r63639 patch.
Modified:
llvm/branches/Apple/Dib/include/llvm/CodeGen/DebugLoc.h
llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
llvm/branches/Apple/Dib/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
Modified: llvm/branches/Apple/Dib/include/llvm/CodeGen/DebugLoc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/include/llvm/CodeGen/DebugLoc.h?rev=64714&r1=64713&r2=64714&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/include/llvm/CodeGen/DebugLoc.h (original)
+++ llvm/branches/Apple/Dib/include/llvm/CodeGen/DebugLoc.h Mon Feb 16 19:02:43 2009
@@ -37,17 +37,14 @@
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); }
Modified: llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=64714&r1=64713&r2=64714&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Feb 16 19:02:43 2009
@@ -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"
@@ -1289,17 +1290,23 @@
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.
- if (useDEBUG_LOC) {
- SDValue Ops[] = { Tmp1, DAG.getConstant(Line, MVT::i32),
+
+ 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),
DAG.getConstant(SrcFile, MVT::i32) };
- Result = DAG.getNode(ISD::DEBUG_LOC, dl, MVT::Other, Ops, 4);
+ Result = DAG.getNode(ISD::DEBUG_LOC, dl, MVT::Other, Ops, 4);
+ } else {
+ unsigned ID = DW->RecordSourceLine(Line, Col, SrcFile);
+ Result = DAG.getLabel(ISD::DBG_LABEL, dl, Tmp1, ID);
+ }
} else {
- unsigned ID = DW->RecordSourceLine(Line, Col, SrcFile);
- Result = DAG.getLabel(ISD::DBG_LABEL, dl, Tmp1, ID);
+ Result = Tmp1; // chain
}
} else {
Result = Tmp1; // chain
Modified: llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=64714&r1=64713&r2=64714&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon Feb 16 19:02:43 2009
@@ -3915,8 +3915,12 @@
if (DW && DW->ValidDebugInfo(RSI.getContext())) {
unsigned LabelID =
DW->RecordRegionStart(cast<GlobalVariable>(RSI.getContext()));
- DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
- getRoot(), LabelID));
+ 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));
}
return 0;
@@ -3927,8 +3931,12 @@
if (DW && DW->ValidDebugInfo(REI.getContext())) {
unsigned LabelID =
DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext()));
- DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
- getRoot(), LabelID));
+ 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));
}
return 0;
@@ -3950,28 +3958,36 @@
// 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);
- if (DW->getRecordSourceLineCount() != 1)
- DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
- getRoot(), LabelID));
+ // 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)));
+ getOrCreateDebugLocID(SrcFile, Line, 0)));
}
return 0;
}
case Intrinsic::dbg_declare: {
- 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)));
+ 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.
Modified: llvm/branches/Apple/Dib/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=64714&r1=64713&r2=64714&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Mon Feb 16 19:02:43 2009
@@ -726,15 +726,20 @@
++EmittedInsts;
if (TAI->doesSupportDebugInformation()) {
- static DebugLoc PrevDL = DebugLoc::getUnknownLoc();
- DebugLoc CurDL = MI->getDebugLoc();
+ const Function *F = MF->getFunction();
- if (!CurDL.isInvalid() && !CurDL.isUnknown() && PrevDL != CurDL) {
- DebugLocTuple DLT = MF->getDebugLocTuple(CurDL);
- printLabel(DW->RecordSourceLine(DLT.Line, DLT.Col, DLT.Src));
- }
+ // FIXME: Support more than '-Os'.
+ if (F->hasFnAttr(Attribute::OptimizeForSize)) {
+ static DebugLoc PrevDL = DebugLoc::getUnknownLoc();
+ DebugLoc CurDL = MI->getDebugLoc();
+
+ if (!CurDL.isUnknown() && PrevDL != CurDL) {
+ DebugLocTuple DLT = MF->getDebugLocTuple(CurDL);
+ printLabel(DW->RecordSourceLine(DLT.Line, DLT.Col, DLT.Src));
+ }
- PrevDL = CurDL;
+ PrevDL = CurDL;
+ }
}
// Call the autogenerated instruction printer routines.
More information about the llvm-commits
mailing list