Index: llvm/include/llvm/CodeGen/AsmPrinter.h =================================================================== --- llvm/include/llvm/CodeGen/AsmPrinter.h +++ llvm/include/llvm/CodeGen/AsmPrinter.h @@ -707,7 +707,7 @@ /// ${:comment}. Targets can override this to add support for their own /// strange codes. virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS, - const char *Code) const; + StringRef Code) const; /// Print the MachineOperand as a symbol. Targets with complex handling of /// symbol references should override the base implementation. Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -184,8 +184,7 @@ report_fatal_error("Unterminated ${:foo} operand in inline asm" " string: '" + Twine(AsmStr) + "'"); - std::string Val(StrStart, StrEnd); - AP->PrintSpecial(MI, OS, Val.c_str()); + AP->PrintSpecial(MI, OS, StringRef(StrStart, StrEnd - StrStart)); LastEmitted = StrEnd+1; break; } @@ -351,10 +350,8 @@ if (!StrEnd) report_fatal_error("Unterminated ${:foo} operand in inline asm" " string: '" + Twine(AsmStr) + "'"); - if (CurVariant == -1 || CurVariant == AsmPrinterVariant) { - std::string Val(StrStart, StrEnd); - AP->PrintSpecial(MI, OS, Val.c_str()); - } + if (CurVariant == -1 || CurVariant == AsmPrinterVariant) + AP->PrintSpecial(MI, OS, StringRef(StrStart, StrEnd - StrStart)); LastEmitted = StrEnd+1; break; } @@ -561,13 +558,13 @@ /// syntax used is ${:comment}. Targets can override this to add support /// for their own strange codes. void AsmPrinter::PrintSpecial(const MachineInstr *MI, raw_ostream &OS, - const char *Code) const { - if (!strcmp(Code, "private")) { + StringRef Code) const { + if (Code == "private") { const DataLayout &DL = MF->getDataLayout(); OS << DL.getPrivateGlobalPrefix(); - } else if (!strcmp(Code, "comment")) { + } else if (Code == "comment") { OS << MAI->getCommentString(); - } else if (!strcmp(Code, "uid")) { + } else if (Code == "uid") { // Comparing the address of MI isn't sufficient, because machineinstrs may // be allocated to the same address across functions.