[AutoUpgrade] Fix length check for intrinsic upgrade
authorNikita Popov <npopov@redhat.com>
Fri, 21 Oct 2022 08:49:45 +0000 (10:49 +0200)
committerNikita Popov <npopov@redhat.com>
Fri, 21 Oct 2022 08:53:06 +0000 (10:53 +0200)
The shortest intrinsics that can be upgraded via remangling have
8 characters (like "llvm.abs"). Make sure these go through the
upgrade code.

I think that currently this change is not observable from in-tree
callers of UpgradeIntrinsicFunction(), because callers do
redundant remangling checks. However, this issue shows up in
existing tests if those checks are removed (which I will do in
followup changes).

llvm/lib/IR/AutoUpgrade.cpp

index ebc362a..5ecf344 100644 (file)
@@ -583,7 +583,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
 
   // Quickly eliminate it, if it's not a candidate.
   StringRef Name = F->getName();
-  if (Name.size() <= 8 || !Name.startswith("llvm."))
+  if (Name.size() <= 7 || !Name.startswith("llvm."))
     return false;
   Name = Name.substr(5); // Strip off "llvm."