[llvm] [NFC][LLVM] Minor code cleanup in BitcodeReader (PR #206105)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 26 08:09:26 PDT 2026
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/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.
>From 6c6f5449f99ffed1b2f934fcbe9fd3098265709e Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Fri, 26 Jun 2026 08:05:54 -0700
Subject: [PATCH] [NFC][LLVM] Minor code cleanup in BitcodeReader
Use structured binding in the range for loop for iterating over
upgraded intrinsics. Also `UpdatedIntrinsicMap` type alias is
used just once, so eliminate it.
---
llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
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