[llvm] [Utils] Use StringRef::starts_with (NFC) (PR #138379)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri May 2 22:45:50 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/138379
None
>From 86d5372b60efc6dbd14ccfb63556763d0194deda Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 2 May 2025 22:39:43 -0700
Subject: [PATCH] [Utils] Use StringRef::starts_with (NFC)
---
llvm/lib/Transforms/Utils/IRNormalizer.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Utils/IRNormalizer.cpp b/llvm/lib/Transforms/Utils/IRNormalizer.cpp
index 75e775086493a..fd355ff9294cc 100644
--- a/llvm/lib/Transforms/Utils/IRNormalizer.cpp
+++ b/llvm/lib/Transforms/Utils/IRNormalizer.cpp
@@ -367,7 +367,7 @@ void IRNormalizer::foldInstructionName(Instruction *I) const {
}
// Don't fold if it is an output instruction or has no op prefix.
- if (isOutput(I) || I->getName().substr(0, 2) != "op")
+ if (isOutput(I) || !I->getName().starts_with("op"))
return;
// Instruction operands.
@@ -375,8 +375,8 @@ void IRNormalizer::foldInstructionName(Instruction *I) const {
for (auto &Op : I->operands()) {
if (const auto *I = dyn_cast<Instruction>(Op)) {
- bool HasNormalName = I->getName().substr(0, 2) == "op" ||
- I->getName().substr(0, 2) == "vl";
+ bool HasNormalName =
+ I->getName().starts_with("op") || I->getName().starts_with("vl");
Operands.push_back(HasNormalName ? I->getName().substr(0, 7)
: I->getName());
More information about the llvm-commits
mailing list