Skip to content

Commit 50e949f

Browse files
[IR] Teach getAsmString to return StringRef (NFC) (#139406)
This is for consistency with #139401.
1 parent 2a0e886 commit 50e949f

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

llvm/include/llvm/IR/InlineAsm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class InlineAsm final : public Value {
8383
///
8484
FunctionType *getFunctionType() const;
8585

86-
const std::string &getAsmString() const { return AsmString; }
86+
StringRef getAsmString() const { return AsmString; }
8787
StringRef getConstraintString() const { return Constraints; }
8888
void collectAsmStrs(SmallVectorImpl<StringRef> &AsmStrs) const;
8989

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2800,7 +2800,7 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
28002800
unsigned(IA->getDialect() & 1) << 2 | unsigned(IA->canThrow()) << 3);
28012801

28022802
// Add the asm string.
2803-
const std::string &AsmStr = IA->getAsmString();
2803+
StringRef AsmStr = IA->getAsmString();
28042804
Record.push_back(AsmStr.size());
28052805
Record.append(AsmStr.begin(), AsmStr.end());
28062806

llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ bool InlineAsmLowering::lowerInlineAsm(
297297
// Create the MachineInstr, but don't insert it yet since input
298298
// operands still need to insert instructions before this one
299299
auto Inst = MIRBuilder.buildInstrNoInsert(TargetOpcode::INLINEASM)
300-
.addExternalSymbol(IA->getAsmString().c_str())
300+
.addExternalSymbol(IA->getAsmString().data())
301301
.addImm(ExtraInfo.get());
302302

303303
// Starting from this operand: flag followed by register(s) will be added as

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ bool FastISel::selectCall(const User *I) {
11731173

11741174
MachineInstrBuilder MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
11751175
TII.get(TargetOpcode::INLINEASM));
1176-
MIB.addExternalSymbol(IA->getAsmString().c_str());
1176+
MIB.addExternalSymbol(IA->getAsmString().data());
11771177
MIB.addImm(ExtraInfo);
11781178

11791179
const MDNode *SrcLoc = Call->getMetadata("srcloc");

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10017,7 +10017,7 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
1001710017
std::vector<SDValue> AsmNodeOperands;
1001810018
AsmNodeOperands.push_back(SDValue()); // reserve space for input chain
1001910019
AsmNodeOperands.push_back(DAG.getTargetExternalSymbol(
10020-
IA->getAsmString().c_str(), TLI.getProgramPointerTy(DAG.getDataLayout())));
10020+
IA->getAsmString().data(), TLI.getProgramPointerTy(DAG.getDataLayout())));
1002110021

1002210022
// If we have a !srcloc metadata node associated with it, we want to attach
1002310023
// this to the ultimately generated inline asm machineinstr. To do this, we

llvm/lib/IR/Core.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,10 @@ LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, const char *AsmString,
520520
const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len) {
521521

522522
Value *Val = unwrap<Value>(InlineAsmVal);
523-
const std::string &AsmString = cast<InlineAsm>(Val)->getAsmString();
523+
StringRef AsmString = cast<InlineAsm>(Val)->getAsmString();
524524

525-
*Len = AsmString.length();
526-
return AsmString.c_str();
525+
*Len = AsmString.size();
526+
return AsmString.data();
527527
}
528528

529529
const char *LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal,

llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ NVPTXTTIImpl::getInstructionCost(const User *U,
492492
// since it is classified as a call in the IR. A better cost model would
493493
// be to return the number of asm instructions embedded in the asm
494494
// string.
495-
auto &AsmStr = IA->getAsmString();
495+
StringRef AsmStr = IA->getAsmString();
496496
const unsigned InstCount =
497497
count_if(split(AsmStr, ';'), [](StringRef AsmInst) {
498498
// Trim off scopes denoted by '{' and '}' as these can be ignored

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60829,7 +60829,7 @@ static bool clobbersFlagRegisters(const SmallVector<StringRef, 4> &AsmPieces) {
6082960829
bool X86TargetLowering::ExpandInlineAsm(CallInst *CI) const {
6083060830
InlineAsm *IA = cast<InlineAsm>(CI->getCalledOperand());
6083160831

60832-
const std::string &AsmStr = IA->getAsmString();
60832+
StringRef AsmStr = IA->getAsmString();
6083360833

6083460834
IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
6083560835
if (!Ty || Ty->getBitWidth() % 16 != 0)

0 commit comments

Comments
 (0)