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(AsmStrV)->getSymbol(); - MIB.addExternalSymbol(AsmStr); + const Value *SrcVal = cast(AsmStrV)->getValue(); + MIB.addExternalSymbol(cast(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(Node)) return true; if (Node->getOpcode() == ISD::EntryToken || isa(Node)) return true; + if (auto *SV = dyn_cast(Node)) + if (isa(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 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(cast(NodeToMatch)->getValue())) { + NodeToMatch->setNodeId(-1); + return nullptr; + } + break; } assert(!NodeToMatch->isMachineOpcode() && "Node already selected!");