diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1178,7 +1178,7 @@ } /// Returns a string of target-specific clobbers, in LLVM format. - virtual const char *getClobbers() const = 0; + virtual std::string_view getClobbers() const = 0; /// Returns true if NaN encoding is IEEE 754-2008. /// Only MIPS allows a different encoding. diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -192,7 +192,7 @@ bool validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size, std::string &SuggestedModifier) const override; - const char *getClobbers() const override; + std::string_view getClobbers() const override; StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const override { diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -1295,7 +1295,7 @@ } } -const char *AArch64TargetInfo::getClobbers() const { return ""; } +std::string_view AArch64TargetInfo::getClobbers() const { return ""; } int AArch64TargetInfo::getEHDataRegisterNumber(unsigned RegNo) const { if (RegNo == 0) diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -117,7 +117,7 @@ bool hasBFloat16Type() const override { return isAMDGCN(getTriple()); } const char *getBFloat16Mangling() const override { return "u6__bf16"; }; - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } ArrayRef getGCCRegNames() const override; diff --git a/clang/lib/Basic/Targets/ARC.h b/clang/lib/Basic/Targets/ARC.h --- a/clang/lib/Basic/Targets/ARC.h +++ b/clang/lib/Basic/Targets/ARC.h @@ -48,7 +48,7 @@ return TargetInfo::VoidPtrBuiltinVaList; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } ArrayRef getGCCRegNames() const override { static const char *const GCCRegNames[] = { diff --git a/clang/lib/Basic/Targets/ARM.h b/clang/lib/Basic/Targets/ARM.h --- a/clang/lib/Basic/Targets/ARM.h +++ b/clang/lib/Basic/Targets/ARM.h @@ -181,7 +181,7 @@ bool validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size, std::string &SuggestedModifier) const override; - const char *getClobbers() const override; + std::string_view getClobbers() const override; StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const override { diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp --- a/clang/lib/Basic/Targets/ARM.cpp +++ b/clang/lib/Basic/Targets/ARM.cpp @@ -1244,7 +1244,7 @@ return true; } -const char *ARMTargetInfo::getClobbers() const { +std::string_view ARMTargetInfo::getClobbers() const { // FIXME: Is this really right? return ""; } diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h --- a/clang/lib/Basic/Targets/AVR.h +++ b/clang/lib/Basic/Targets/AVR.h @@ -69,7 +69,7 @@ return TargetInfo::VoidPtrBuiltinVaList; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } ArrayRef getGCCRegNames() const override { static const char *const GCCRegNames[] = { diff --git a/clang/lib/Basic/Targets/BPF.h b/clang/lib/Basic/Targets/BPF.h --- a/clang/lib/Basic/Targets/BPF.h +++ b/clang/lib/Basic/Targets/BPF.h @@ -60,7 +60,7 @@ ArrayRef getTargetBuiltins() const override; - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; diff --git a/clang/lib/Basic/Targets/CSKY.h b/clang/lib/Basic/Targets/CSKY.h --- a/clang/lib/Basic/Targets/CSKY.h +++ b/clang/lib/Basic/Targets/CSKY.h @@ -82,7 +82,7 @@ bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override; - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; diff --git a/clang/lib/Basic/Targets/DirectX.h b/clang/lib/Basic/Targets/DirectX.h --- a/clang/lib/Basic/Targets/DirectX.h +++ b/clang/lib/Basic/Targets/DirectX.h @@ -77,7 +77,7 @@ return std::nullopt; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } ArrayRef getGCCRegNames() const override { return std::nullopt; diff --git a/clang/lib/Basic/Targets/Hexagon.h b/clang/lib/Basic/Targets/Hexagon.h --- a/clang/lib/Basic/Targets/Hexagon.h +++ b/clang/lib/Basic/Targets/Hexagon.h @@ -112,7 +112,7 @@ ArrayRef getGCCRegAliases() const override; - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } static const char *getHexagonCPUSuffix(StringRef Name); diff --git a/clang/lib/Basic/Targets/Lanai.h b/clang/lib/Basic/Targets/Lanai.h --- a/clang/lib/Basic/Targets/Lanai.h +++ b/clang/lib/Basic/Targets/Lanai.h @@ -87,7 +87,7 @@ return false; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } bool hasBitIntType() const override { return true; } }; diff --git a/clang/lib/Basic/Targets/Le64.h b/clang/lib/Basic/Targets/Le64.h --- a/clang/lib/Basic/Targets/Le64.h +++ b/clang/lib/Basic/Targets/Le64.h @@ -41,7 +41,7 @@ return TargetInfo::PNaClABIBuiltinVaList; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } ArrayRef getGCCRegNames() const override { return std::nullopt; diff --git a/clang/lib/Basic/Targets/LoongArch.h b/clang/lib/Basic/Targets/LoongArch.h --- a/clang/lib/Basic/Targets/LoongArch.h +++ b/clang/lib/Basic/Targets/LoongArch.h @@ -51,7 +51,7 @@ return TargetInfo::VoidPtrBuiltinVaList; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } ArrayRef getGCCRegNames() const override; diff --git a/clang/lib/Basic/Targets/M68k.h b/clang/lib/Basic/Targets/M68k.h --- a/clang/lib/Basic/Targets/M68k.h +++ b/clang/lib/Basic/Targets/M68k.h @@ -49,7 +49,7 @@ bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override; std::optional handleAsmEscapedChar(char EscChar) const override; - const char *getClobbers() const override; + std::string_view getClobbers() const override; BuiltinVaListKind getBuiltinVaListKind() const override; bool setCPU(const std::string &Name) override; }; diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp --- a/clang/lib/Basic/Targets/M68k.cpp +++ b/clang/lib/Basic/Targets/M68k.cpp @@ -236,7 +236,7 @@ return std::string(1, *Constraint); } -const char *M68kTargetInfo::getClobbers() const { +std::string_view M68kTargetInfo::getClobbers() const { // FIXME: Is this really right? return ""; } diff --git a/clang/lib/Basic/Targets/MSP430.h b/clang/lib/Basic/Targets/MSP430.h --- a/clang/lib/Basic/Targets/MSP430.h +++ b/clang/lib/Basic/Targets/MSP430.h @@ -87,7 +87,7 @@ return false; } - const char *getClobbers() const override { + std::string_view getClobbers() const override { // FIXME: Is this really right? return ""; } diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h --- a/clang/lib/Basic/Targets/Mips.h +++ b/clang/lib/Basic/Targets/Mips.h @@ -278,7 +278,7 @@ return TargetInfo::convertConstraint(Constraint); } - const char *getClobbers() const override { + std::string_view getClobbers() const override { // In GCC, $1 is not widely used in generated code (it's used only in a few // specific situations), so there is no real need for users to add it to // the clobbers list if they want to use it in their inline assembly code. diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h --- a/clang/lib/Basic/Targets/NVPTX.h +++ b/clang/lib/Basic/Targets/NVPTX.h @@ -109,7 +109,7 @@ } } - const char *getClobbers() const override { + std::string_view getClobbers() const override { // FIXME: Is this really right? return ""; } diff --git a/clang/lib/Basic/Targets/PNaCl.h b/clang/lib/Basic/Targets/PNaCl.h --- a/clang/lib/Basic/Targets/PNaCl.h +++ b/clang/lib/Basic/Targets/PNaCl.h @@ -69,7 +69,7 @@ return false; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } bool hasBitIntType() const override { return true; } }; diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h --- a/clang/lib/Basic/Targets/PPC.h +++ b/clang/lib/Basic/Targets/PPC.h @@ -330,7 +330,7 @@ return R; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } int getEHDataRegisterNumber(unsigned RegNo) const override { if (RegNo == 0) return 3; diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h --- a/clang/lib/Basic/Targets/RISCV.h +++ b/clang/lib/Basic/Targets/RISCV.h @@ -60,7 +60,7 @@ return TargetInfo::VoidPtrBuiltinVaList; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const override { diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h --- a/clang/lib/Basic/Targets/SPIR.h +++ b/clang/lib/Basic/Targets/SPIR.h @@ -164,7 +164,7 @@ return std::nullopt; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } ArrayRef getGCCRegNames() const override { return std::nullopt; diff --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h --- a/clang/lib/Basic/Targets/Sparc.h +++ b/clang/lib/Basic/Targets/Sparc.h @@ -77,7 +77,7 @@ } return false; } - const char *getClobbers() const override { + std::string_view getClobbers() const override { // FIXME: Implement! return ""; } diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -106,7 +106,7 @@ return TargetInfo::convertConstraint(Constraint); } - const char *getClobbers() const override { + std::string_view getClobbers() const override { // FIXME: Is this really right? return ""; } diff --git a/clang/lib/Basic/Targets/TCE.h b/clang/lib/Basic/Targets/TCE.h --- a/clang/lib/Basic/Targets/TCE.h +++ b/clang/lib/Basic/Targets/TCE.h @@ -99,7 +99,7 @@ return std::nullopt; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; diff --git a/clang/lib/Basic/Targets/VE.h b/clang/lib/Basic/Targets/VE.h --- a/clang/lib/Basic/Targets/VE.h +++ b/clang/lib/Basic/Targets/VE.h @@ -69,7 +69,7 @@ } } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } ArrayRef getGCCRegNames() const override { static const char *const GCCRegNames[] = { diff --git a/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h --- a/clang/lib/Basic/Targets/WebAssembly.h +++ b/clang/lib/Basic/Targets/WebAssembly.h @@ -130,7 +130,7 @@ return false; } - const char *getClobbers() const final { return ""; } + std::string_view getClobbers() const final { return ""; } bool isCLZForZeroUndef() const final { return false; } diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -262,7 +262,7 @@ StringRef Constraint, unsigned Size) const; std::string convertConstraint(const char *&Constraint) const override; - const char *getClobbers() const override { + std::string_view getClobbers() const override { return "~{dirflag},~{fpsr},~{flags}"; } diff --git a/clang/lib/Basic/Targets/XCore.h b/clang/lib/Basic/Targets/XCore.h --- a/clang/lib/Basic/Targets/XCore.h +++ b/clang/lib/Basic/Targets/XCore.h @@ -49,7 +49,7 @@ return TargetInfo::VoidPtrBuiltinVaList; } - const char *getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return ""; } ArrayRef getGCCRegNames() const override { static const char *const GCCRegNames[] = { diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -939,7 +939,7 @@ // Build the constraints. FIXME: We should support immediates when possible. std::string Constraints = "={@ccc},r,r,~{cc},~{memory}"; - std::string MachineClobbers = CGF.getTarget().getClobbers(); + std::string_view MachineClobbers = CGF.getTarget().getClobbers(); if (!MachineClobbers.empty()) { Constraints += ','; Constraints += MachineClobbers; @@ -1082,7 +1082,7 @@ AsmOS << "$0, ${1:y}"; std::string Constraints = "=r,*Z,~{memory}"; - std::string MachineClobbers = CGF.getTarget().getClobbers(); + std::string_view MachineClobbers = CGF.getTarget().getClobbers(); if (!MachineClobbers.empty()) { Constraints += ','; Constraints += MachineClobbers; diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -2779,7 +2779,7 @@ "unwind clobber can't be used with asm goto"); // Add machine specific clobbers - std::string MachineClobbers = getTarget().getClobbers(); + std::string_view MachineClobbers = getTarget().getClobbers(); if (!MachineClobbers.empty()) { if (!Constraints.empty()) Constraints += ',';