[PATCH] D129015: Don't recalculate intrinsic id in Value::setName()

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 13:54:20 PDT 2022


aeubanks created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129015

Files:
  llvm/include/llvm/IR/Function.h
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Value.cpp


Index: llvm/lib/IR/Value.cpp
===================================================================
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -371,8 +371,6 @@
 
 void Value::setName(const Twine &NewName) {
   setNameImpl(NewName);
-  if (Function *F = dyn_cast<Function>(this))
-    F->recalculateIntrinsicID();
 }
 
 void Value::takeName(Value *V) {
Index: llvm/lib/IR/Function.cpp
===================================================================
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -399,7 +399,13 @@
   if (ParentModule)
     ParentModule->getFunctionList().push_back(this);
 
-  HasLLVMReservedName = getName().startswith("llvm.");
+  if (getName().startswith("llvm.")) {
+    HasLLVMReservedName = true;
+    IntID = lookupIntrinsicID(getName());
+  } else {
+    HasLLVMReservedName = false;
+    IntID = Intrinsic::not_intrinsic;
+  }
   // Ensure intrinsics have the right parameter attributes.
   // Note, the IntID field will have been set in Value::setName if this function
   // name is a valid intrinsic ID.
@@ -787,17 +793,6 @@
                                                      : Intrinsic::not_intrinsic;
 }
 
-void Function::recalculateIntrinsicID() {
-  StringRef Name = getName();
-  if (!Name.startswith("llvm.")) {
-    HasLLVMReservedName = false;
-    IntID = Intrinsic::not_intrinsic;
-    return;
-  }
-  HasLLVMReservedName = true;
-  IntID = lookupIntrinsicID(Name);
-}
-
 /// Returns a stable mangling for the type specified for use in the name
 /// mangling scheme used by 'any' types in intrinsic signatures.  The mangling
 /// of named types is simply their name.  Manglings for unnamed types consist
Index: llvm/include/llvm/IR/Function.h
===================================================================
--- llvm/include/llvm/IR/Function.h
+++ llvm/include/llvm/IR/Function.h
@@ -225,13 +225,6 @@
 
   static Intrinsic::ID lookupIntrinsicID(StringRef Name);
 
-  /// Recalculate the ID for this function if it is an Intrinsic defined
-  /// in llvm/Intrinsics.h.  Sets the intrinsic ID to Intrinsic::not_intrinsic
-  /// if the name of this function does not match an intrinsic in that header.
-  /// Note, this method does not need to be called directly, as it is called
-  /// from Value::setName() whenever the name of this function changes.
-  void recalculateIntrinsicID();
-
   /// getCallingConv()/setCallingConv(CC) - These method get and set the
   /// calling convention of this function.  The enum values for the known
   /// calling conventions are defined in CallingConv.h.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129015.441785.patch
Type: text/x-patch
Size: 2562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220701/da70685c/attachment.bin>


More information about the llvm-commits mailing list