[llvm-commits] [llvm] r53246 - in /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp SelectionDAG.cpp
Evan Cheng
evan.cheng at apple.com
Tue Jul 8 13:06:44 PDT 2008
Author: evancheng
Date: Tue Jul 8 15:06:39 2008
New Revision: 53246
URL: http://llvm.org/viewvc/llvm-project?rev=53246&view=rev
Log:
Do not CSE DEBUG_LOC, DBG_LABEL, DBG_STOPPOINT, DECLARE, and EH_LABEL SDNode's. This improves compile time slightly at -O0 -g.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=53246&r1=53245&r2=53246&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Jul 8 15:06:39 2008
@@ -1094,12 +1094,10 @@
unsigned Col = DSP->getColumn();
if (useDEBUG_LOC) {
- SmallVector<SDOperand, 8> Ops;
- Ops.push_back(Tmp1); // chain
- Ops.push_back(DAG.getConstant(Line, MVT::i32)); // line #
- Ops.push_back(DAG.getConstant(Col, MVT::i32)); // col #
- Ops.push_back(DAG.getConstant(SrcFile, MVT::i32)); // source file id
- Result = DAG.getNode(ISD::DEBUG_LOC, MVT::Other, &Ops[0], Ops.size());
+ SDOperand Ops[] = { Tmp1, DAG.getConstant(Line, MVT::i32),
+ DAG.getConstant(Col, MVT::i32),
+ DAG.getConstant(SrcFile, MVT::i32) };
+ Result = DAG.getNode(ISD::DEBUG_LOC, MVT::Other, Ops, 4);
} else {
unsigned ID = MMI->RecordSourceLine(Line, Col, SrcFile);
Result = DAG.getLabel(ISD::DBG_LABEL, Tmp1, ID);
@@ -1109,25 +1107,27 @@
}
break;
}
- case TargetLowering::Legal:
- if (Tmp1 != Node->getOperand(0) ||
- getTypeAction(Node->getOperand(1).getValueType()) == Promote) {
- SmallVector<SDOperand, 8> Ops;
- Ops.push_back(Tmp1);
- if (getTypeAction(Node->getOperand(1).getValueType()) == Legal) {
- Ops.push_back(Node->getOperand(1)); // line # must be legal.
- Ops.push_back(Node->getOperand(2)); // col # must be legal.
- } else {
- // Otherwise promote them.
- Ops.push_back(PromoteOp(Node->getOperand(1)));
- Ops.push_back(PromoteOp(Node->getOperand(2)));
- }
- Ops.push_back(Node->getOperand(3)); // filename must be legal.
- Ops.push_back(Node->getOperand(4)); // working dir # must be legal.
- Result = DAG.UpdateNodeOperands(Result, &Ops[0], Ops.size());
+ case TargetLowering::Legal: {
+ LegalizeAction Action = getTypeAction(Node->getOperand(1).getValueType());
+ if (Action == Legal && Tmp1 == Node->getOperand(0))
+ break;
+
+ SmallVector<SDOperand, 8> Ops;
+ Ops.push_back(Tmp1);
+ if (Action == Legal) {
+ Ops.push_back(Node->getOperand(1)); // line # must be legal.
+ Ops.push_back(Node->getOperand(2)); // col # must be legal.
+ } else {
+ // Otherwise promote them.
+ Ops.push_back(PromoteOp(Node->getOperand(1)));
+ Ops.push_back(PromoteOp(Node->getOperand(2)));
}
+ Ops.push_back(Node->getOperand(3)); // filename must be legal.
+ Ops.push_back(Node->getOperand(4)); // working dir # must be legal.
+ Result = DAG.UpdateNodeOperands(Result, &Ops[0], Ops.size());
break;
}
+ }
break;
case ISD::DECLARE:
@@ -1150,14 +1150,24 @@
assert(Node->getNumOperands() == 4 && "Invalid DEBUG_LOC node!");
switch (TLI.getOperationAction(ISD::DEBUG_LOC, MVT::Other)) {
default: assert(0 && "This action is not supported yet!");
- case TargetLowering::Legal:
+ case TargetLowering::Legal: {
+ LegalizeAction Action = getTypeAction(Node->getOperand(1).getValueType());
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
- Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the line #.
- Tmp3 = LegalizeOp(Node->getOperand(2)); // Legalize the col #.
- Tmp4 = LegalizeOp(Node->getOperand(3)); // Legalize the source file id.
+ if (Action == Legal && Tmp1 == Node->getOperand(0))
+ break;
+ if (Action == Legal) {
+ Tmp2 = Node->getOperand(1);
+ Tmp3 = Node->getOperand(2);
+ Tmp4 = Node->getOperand(3);
+ } else {
+ Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the line #.
+ Tmp3 = LegalizeOp(Node->getOperand(2)); // Legalize the col #.
+ Tmp4 = LegalizeOp(Node->getOperand(3)); // Legalize the source file id.
+ }
Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2, Tmp3, Tmp4);
break;
}
+ }
break;
case ISD::DBG_LABEL:
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=53246&r1=53245&r2=53246&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Jul 8 15:06:39 2008
@@ -395,10 +395,6 @@
ID.AddPointer(DSP->getCompileUnit());
break;
}
- case ISD::DBG_LABEL:
- case ISD::EH_LABEL:
- ID.AddInteger(cast<LabelSDNode>(N)->getLabelID());
- break;
case ISD::SRCVALUE:
ID.AddPointer(cast<SrcValueSDNode>(N)->getValue());
break;
@@ -607,7 +603,11 @@
// flag result (which cannot be CSE'd) or is one of the special cases that are
// not subject to CSE.
if (!Erased && N->getValueType(N->getNumValues()-1) != MVT::Flag &&
- !N->isTargetOpcode()) {
+ !N->isTargetOpcode() &&
+ N->getOpcode() != ISD::DBG_LABEL &&
+ N->getOpcode() != ISD::DBG_STOPPOINT &&
+ N->getOpcode() != ISD::EH_LABEL &&
+ N->getOpcode() != ISD::DECLARE) {
N->dump(this);
cerr << "\n";
assert(0 && "Node is not in map!");
@@ -622,8 +622,19 @@
///
SDNode *SelectionDAG::AddNonLeafNodeToCSEMaps(SDNode *N) {
assert(N->getNumOperands() && "This is a leaf node!");
- if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
+
+ if (N->getValueType(0) == MVT::Flag)
+ return 0; // Never CSE anything that produces a flag.
+
+ switch (N->getOpcode()) {
+ default: break;
+ case ISD::HANDLENODE:
+ case ISD::DBG_LABEL:
+ case ISD::DBG_STOPPOINT:
+ case ISD::EH_LABEL:
+ case ISD::DECLARE:
return 0; // Never add these nodes.
+ }
// Check that remaining values produced are not flags.
for (unsigned i = 1, e = N->getNumValues(); i != e; ++i)
@@ -641,8 +652,17 @@
/// node already exists with these operands, the slot will be non-null.
SDNode *SelectionDAG::FindModifiedNodeSlot(SDNode *N, SDOperand Op,
void *&InsertPos) {
- if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
+ if (N->getValueType(0) == MVT::Flag)
+ return 0; // Never CSE anything that produces a flag.
+
+ switch (N->getOpcode()) {
+ default: break;
+ case ISD::HANDLENODE:
+ case ISD::DBG_LABEL:
+ case ISD::DBG_STOPPOINT:
+ case ISD::EH_LABEL:
return 0; // Never add these nodes.
+ }
// Check that remaining values produced are not flags.
for (unsigned i = 1, e = N->getNumValues(); i != e; ++i)
@@ -663,7 +683,6 @@
SDOperand Op1, SDOperand Op2,
void *&InsertPos) {
if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
- return 0; // Never add these nodes.
// Check that remaining values produced are not flags.
for (unsigned i = 1, e = N->getNumValues(); i != e; ++i)
@@ -684,8 +703,18 @@
SDNode *SelectionDAG::FindModifiedNodeSlot(SDNode *N,
const SDOperand *Ops,unsigned NumOps,
void *&InsertPos) {
- if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
+ if (N->getValueType(0) == MVT::Flag)
+ return 0; // Never CSE anything that produces a flag.
+
+ switch (N->getOpcode()) {
+ default: break;
+ case ISD::HANDLENODE:
+ case ISD::DBG_LABEL:
+ case ISD::DBG_STOPPOINT:
+ case ISD::EH_LABEL:
+ case ISD::DECLARE:
return 0; // Never add these nodes.
+ }
// Check that remaining values produced are not flags.
for (unsigned i = 1, e = N->getNumValues(); i != e; ++i)
@@ -1010,18 +1039,8 @@
SDOperand SelectionDAG::getDbgStopPoint(SDOperand Root,
unsigned Line, unsigned Col,
const CompileUnitDesc *CU) {
- FoldingSetNodeID ID;
- SDOperand Ops[] = { Root };
- AddNodeIDNode(ID, ISD::DBG_STOPPOINT, getVTList(MVT::Other), &Ops[0], 1);
- ID.AddInteger(Line);
- ID.AddInteger(Col);
- ID.AddPointer(CU);
- void *IP = 0;
- if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
- return SDOperand(E, 0);
SDNode *N = getAllocator().Allocate<DbgStopPointSDNode>();
new (N) DbgStopPointSDNode(Root, Line, Col, CU);
- CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
return SDOperand(N, 0);
}
More information about the llvm-commits
mailing list