[llvm] 531b3bd - [NFC][LLVM] Minor code cleanup in BitcodeReader (#206105)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 29 06:51:48 PDT 2026


Author: Rahul Joshi
Date: 2026-06-29T06:51:43-07:00
New Revision: 531b3bdd03977db8a67a87484ff2051a87744160

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

LOG: [NFC][LLVM] Minor code cleanup in BitcodeReader (#206105)

Use structured binding in the range for loop for iterating over upgraded
intrinsics. Also `UpdatedIntrinsicMap` type alias is used just once, so
eliminate it.

Added: 
    

Modified: 
    llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index f6366061c9b52..2bd251efd05ce 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -642,8 +642,7 @@ class BitcodeReader : public BitcodeReaderBase, public GVMaterializer {
 
   // When intrinsic functions are encountered which require upgrading they are
   // stored here with their replacement function.
-  using UpdatedIntrinsicMap = DenseMap<Function *, Function *>;
-  UpdatedIntrinsicMap UpgradedIntrinsics;
+  DenseMap<Function *, Function *> UpgradedIntrinsics;
 
   // Several operations happen after the module header has been read, but
   // before function bodies are processed. This keeps track of whether
@@ -7218,15 +7217,15 @@ Error BitcodeReader::materializeModule() {
   // delete the old functions to clean up. We can't do this unless the entire
   // module is materialized because there could always be another function body
   // with calls to the old function.
-  for (auto &I : UpgradedIntrinsics) {
-    for (auto *U : I.first->users()) {
-      if (CallInst *CI = dyn_cast<CallInst>(U))
-        UpgradeIntrinsicCall(CI, I.second);
-    }
-    if (I.first != I.second) {
-      if (!I.first->use_empty())
-        I.first->replaceAllUsesWith(I.second);
-      I.first->eraseFromParent();
+  for (auto &[OldFn, NewFn] : UpgradedIntrinsics) {
+    for (User *U : OldFn->users()) {
+      if (auto *CI = dyn_cast<CallInst>(U))
+        UpgradeIntrinsicCall(CI, NewFn);
+    }
+    if (OldFn != NewFn) {
+      if (!OldFn->use_empty())
+        OldFn->replaceAllUsesWith(NewFn);
+      OldFn->eraseFromParent();
     }
   }
   UpgradedIntrinsics.clear();


        


More information about the llvm-commits mailing list