aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-09-15 19:46:03 +0000
committerDan Gohman <gohman@apple.com>2008-09-15 19:46:03 +0000
commit5eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9c (patch)
tree4f5fefe12cb40aa66a64bb645792b7b7c712245e /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parentf19063b33f69dd4c1087f98e7b4d8a9a1155229a (diff)
Re-enable SelectionDAG CSE for calls. It matters in the case of
libcalls, as in this testcase on ARM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56226 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 921d7b060b..793f5c9997 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -423,6 +423,12 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, const SDNode *N) {
ID.AddPointer(CP->getConstVal());
break;
}
+ case ISD::CALL: {
+ const CallSDNode *Call = cast<CallSDNode>(N);
+ ID.AddInteger(Call->getCallingConv());
+ ID.AddInteger(Call->isVarArg());
+ break;
+ }
case ISD::LOAD: {
const LoadSDNode *LD = cast<LoadSDNode>(N);
ID.AddInteger(LD->getAddressingMode());
@@ -636,7 +642,6 @@ bool SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) {
// not subject to CSE.
if (!Erased && N->getValueType(N->getNumValues()-1) != MVT::Flag &&
!N->isMachineOpcode() &&
- N->getOpcode() != ISD::CALL &&
N->getOpcode() != ISD::DBG_LABEL &&
N->getOpcode() != ISD::DBG_STOPPOINT &&
N->getOpcode() != ISD::EH_LABEL &&
@@ -662,7 +667,6 @@ SDNode *SelectionDAG::AddNonLeafNodeToCSEMaps(SDNode *N) {
switch (N->getOpcode()) {
default: break;
- case ISD::CALL:
case ISD::HANDLENODE:
case ISD::DBG_LABEL:
case ISD::DBG_STOPPOINT:
@@ -3310,13 +3314,23 @@ SDValue
SelectionDAG::getCall(unsigned CallingConv, bool IsVarArgs, bool IsTailCall,
SDVTList VTs,
const SDValue *Operands, unsigned NumOperands) {
- // Do not CSE calls. Note that in addition to being a compile-time
- // optimization (since attempting CSE of calls is unlikely to be
- // meaningful), we actually depend on this behavior. CallSDNode can
- // be mutated, which is only safe if calls are not CSE'd.
+ // Do not include isTailCall in the folding set profile.
+ FoldingSetNodeID ID;
+ AddNodeIDNode(ID, ISD::CALL, VTs, Operands, NumOperands);
+ ID.AddInteger(CallingConv);
+ ID.AddInteger(IsVarArgs);
+ void *IP = 0;
+ if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) {
+ // Instead of including isTailCall in the folding set, we just
+ // set the flag of the existing node.
+ if (!IsTailCall)
+ cast<CallSDNode>(E)->setNotTailCall();
+ return SDValue(E, 0);
+ }
SDNode *N = NodeAllocator.Allocate<CallSDNode>();
new (N) CallSDNode(CallingConv, IsVarArgs, IsTailCall,
VTs, Operands, NumOperands);
+ CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
return SDValue(N, 0);
}