Skip to content

Commit c0cb803

Browse files
[IR] Use StringRef::consume_front (NFC)
1 parent 49138d9 commit c0cb803

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,18 +2351,10 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
23512351
assert(Name.starts_with("llvm.") && "Intrinsic doesn't start with 'llvm.'");
23522352
Name = Name.substr(5);
23532353

2354-
bool IsX86 = Name.starts_with("x86.");
2355-
if (IsX86)
2356-
Name = Name.substr(4);
2357-
bool IsNVVM = Name.starts_with("nvvm.");
2358-
if (IsNVVM)
2359-
Name = Name.substr(5);
2360-
bool IsARM = Name.starts_with("arm.");
2361-
if (IsARM)
2362-
Name = Name.substr(4);
2363-
bool IsAMDGCN = Name.starts_with("amdgcn.");
2364-
if (IsAMDGCN)
2365-
Name = Name.substr(7);
2354+
bool IsX86 = Name.consume_front("x86.");
2355+
bool IsNVVM = Name.consume_front("nvvm.");
2356+
bool IsARM = Name.consume_front("arm.");
2357+
bool IsAMDGCN = Name.consume_front("amdgcn.");
23662358

23672359
if (IsX86 && Name.starts_with("sse4a.movnt.")) {
23682360
SmallVector<Metadata *, 1> Elts;

llvm/lib/IR/Globals.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ std::string GlobalValue::getGlobalIdentifier(StringRef Name,
147147
// Value names may be prefixed with a binary '1' to indicate
148148
// that the backend should not modify the symbols due to any platform
149149
// naming convention. Do not include that '1' in the PGO profile name.
150-
if (Name[0] == '\1')
151-
Name = Name.substr(1);
150+
Name.consume_front("\1");
152151

153152
std::string GlobalName;
154153
if (llvm::GlobalValue::isLocalLinkage(Linkage)) {

0 commit comments

Comments
 (0)