[llvm] [llvm] Adjust Autoupdater's llvm prefix detection (PR #74142)
Nathan Sidwell via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 13:17:25 PST 2023
https://github.com/urnathan created https://github.com/llvm/llvm-project/pull/74142
Use consume_front to swallow the 'llvm.' prefix, and 'empty' to check there's at least one character left. It does not seem worth while checking for at least 2 characters left -- any well formed IR will have several characters remaining anyway.
probably the simplest of my autoupdater changes.
>From 287d552a92a87f59f9eb57726f56995bda336350 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan at acm.org>
Date: Sat, 25 Nov 2023 19:29:08 -0500
Subject: [PATCH] [llvm] Adjust Autoupdater's llvm prefix detection
Use consume_front to swallow the 'llvm.' prefix, and 'empty' to check
there's at least one character left. It does not seem worth while
checking for at least 2 characters left -- any well formed IR will
have several characters remaining anyway.
---
llvm/lib/IR/AutoUpgrade.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 9d546d3a5e9b12c..7a40f24661caf1a 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -704,11 +704,11 @@ static Intrinsic::ID ShouldUpgradeNVPTXBF16Intrinsic(StringRef Name) {
static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
assert(F && "Illegal to upgrade a non-existent Function.");
- // Quickly eliminate it, if it's not a candidate.
StringRef Name = F->getName();
- if (Name.size() <= 7 || !Name.starts_with("llvm."))
+
+ // Quickly eliminate it, if it's not a candidate.
+ if (!Name.consume_front("llvm.") || Name.empty())
return false;
- Name = Name.substr(5); // Strip off "llvm."
switch (Name[0]) {
default: break;
More information about the llvm-commits
mailing list