[PATCH] [SDAG] Don't pass inline asm blobs through ExternalSymbolSDNodes
Reid Kleckner
rnk at google.com
Thu May 7 13:58:34 PDT 2015
Hi echristo,
Shoving the string through the ExternalSymbol uniquing hash tables is a
waste of time. Instead, just point at the InlineAsm value from the IR,
and pull the string out later when we lower to MI.
http://reviews.llvm.org/D9575
Files:
lib/CodeGen/SelectionDAG/InstrEmitter.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.h
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Index: lib/CodeGen/SelectionDAG/InstrEmitter.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/InstrEmitter.cpp
+++ lib/CodeGen/SelectionDAG/InstrEmitter.cpp
@@ -940,8 +940,8 @@
// Add the asm string as an external symbol operand.
SDValue AsmStrV = Node->getOperand(InlineAsm::Op_AsmString);
- const char *AsmStr = cast<ExternalSymbolSDNode>(AsmStrV)->getSymbol();
- MIB.addExternalSymbol(AsmStr);
+ const Value *SrcVal = cast<SrcValueSDNode>(AsmStrV)->getValue();
+ MIB.addExternalSymbol(cast<InlineAsm>(SrcVal)->getAsmString().c_str());
// Add the HasSideEffect, isAlignStack, AsmDialect, MayLoad and MayStore
// bits.
Index: lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.h
===================================================================
--- lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.h
+++ lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.h
@@ -67,6 +67,9 @@
if (isa<BlockAddressSDNode>(Node)) return true;
if (Node->getOpcode() == ISD::EntryToken ||
isa<MDNodeSDNode>(Node)) return true;
+ if (auto *SV = dyn_cast<SrcValueSDNode>(Node))
+ if (isa<InlineAsm>(SV->getValue()))
+ return true;
return false;
}
Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5953,9 +5953,7 @@
// AsmNodeOperands - The operands for the ISD::INLINEASM node.
std::vector<SDValue> AsmNodeOperands;
AsmNodeOperands.push_back(SDValue()); // reserve space for input chain
- AsmNodeOperands.push_back(
- DAG.getTargetExternalSymbol(IA->getAsmString().c_str(),
- TLI.getPointerTy()));
+ AsmNodeOperands.push_back(DAG.getSrcValue(IA));
// If we have a !srcloc metadata node associated with it, we want to attach
// this to the ultimately generated inline asm machineinstr. To do this, we
Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -2574,6 +2574,13 @@
case ISD::READ_REGISTER: return Select_READ_REGISTER(NodeToMatch);
case ISD::WRITE_REGISTER: return Select_WRITE_REGISTER(NodeToMatch);
case ISD::UNDEF: return Select_UNDEF(NodeToMatch);
+ case ISD::SRCVALUE:
+ // SrcValues wrapping inline asm are leaves and don't need selection.
+ if (isa<InlineAsm>(cast<SrcValueSDNode>(NodeToMatch)->getValue())) {
+ NodeToMatch->setNodeId(-1);
+ return nullptr;
+ }
+ break;
}
assert(!NodeToMatch->isMachineOpcode() && "Node already selected!");
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9575.25232.patch
Type: text/x-patch
Size: 2833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150507/43233a58/attachment.bin>
More information about the llvm-commits
mailing list