[llvm] d04a4a0 - [llvm] Adjust Autoupdater's llvm prefix detection (#74142)

via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 2 08:57:45 PST 2023


Author: Nathan Sidwell
Date: 2023-12-02T11:57:41-05:00
New Revision: d04a4a06abd4c415d7e433fef1553cfdcddea858

URL: https://github.com/llvm/llvm-project/commit/d04a4a06abd4c415d7e433fef1553cfdcddea858
DIFF: https://github.com/llvm/llvm-project/commit/d04a4a06abd4c415d7e433fef1553cfdcddea858.diff

LOG: [llvm] Adjust Autoupdater's llvm prefix detection (#74142)

Use consume_front to swallow the 'llvm.' prefix, and 'empty' to check
there's at least one character left.

Added: 
    

Modified: 
    llvm/lib/IR/AutoUpgrade.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 9d546d3a5e9b1..7a40f24661caf 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