[llvm] c0cb803 - [IR] Use StringRef::consume_front (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 14 00:53:37 PST 2024
Author: Kazu Hirata
Date: 2024-01-14T00:53:26-08:00
New Revision: c0cb80338f7fe7c6041350481eb3abc28dc28447
URL: https://github.com/llvm/llvm-project/commit/c0cb80338f7fe7c6041350481eb3abc28dc28447
DIFF: https://github.com/llvm/llvm-project/commit/c0cb80338f7fe7c6041350481eb3abc28dc28447.diff
LOG: [IR] Use StringRef::consume_front (NFC)
Added:
Modified:
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Globals.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 3a3b41fb786c2d..1a9e474911b39c 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -2351,18 +2351,10 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
assert(Name.starts_with("llvm.") && "Intrinsic doesn't start with 'llvm.'");
Name = Name.substr(5);
- bool IsX86 = Name.starts_with("x86.");
- if (IsX86)
- Name = Name.substr(4);
- bool IsNVVM = Name.starts_with("nvvm.");
- if (IsNVVM)
- Name = Name.substr(5);
- bool IsARM = Name.starts_with("arm.");
- if (IsARM)
- Name = Name.substr(4);
- bool IsAMDGCN = Name.starts_with("amdgcn.");
- if (IsAMDGCN)
- Name = Name.substr(7);
+ bool IsX86 = Name.consume_front("x86.");
+ bool IsNVVM = Name.consume_front("nvvm.");
+ bool IsARM = Name.consume_front("arm.");
+ bool IsAMDGCN = Name.consume_front("amdgcn.");
if (IsX86 && Name.starts_with("sse4a.movnt.")) {
SmallVector<Metadata *, 1> Elts;
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 239acd2181e854..481a1d802e66b6 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -147,8 +147,7 @@ std::string GlobalValue::getGlobalIdentifier(StringRef Name,
// Value names may be prefixed with a binary '1' to indicate
// that the backend should not modify the symbols due to any platform
// naming convention. Do not include that '1' in the PGO profile name.
- if (Name[0] == '\1')
- Name = Name.substr(1);
+ Name.consume_front("\1");
std::string GlobalName;
if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
More information about the llvm-commits
mailing list