[llvm] [Transforms][NFC] Tiny fixes in SplitModule (PR #95903)

Ilia Sergachev via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 03:13:25 PDT 2024


================
@@ -275,8 +278,8 @@ void llvm::SplitModule(
     ValueToValueMapTy VMap;
     std::unique_ptr<Module> MPart(
         CloneModule(M, VMap, [&](const GlobalValue *GV) {
-          if (ClusterIDMap.count(GV))
-            return (ClusterIDMap[GV] == I);
+          if (auto It = ClusterIDMap.find(GV); It != ClusterIDMap.end())
----------------
sergachev wrote:

Would it? It's a common pattern that reduces the scope of 'It': https://github.com/llvm/llvm-project/blob/9d45077df92a64ff8db5b249ac2f2d45e82ab73c/clang/lib/AST/Interp/Program.cpp#L117, https://github.com/llvm/llvm-project/blob/9d45077df92a64ff8db5b249ac2f2d45e82ab73c/llvm/lib/IR/DebugLoc.cpp#L79, https://github.com/llvm/llvm-project/blob/9d45077df92a64ff8db5b249ac2f2d45e82ab73c/clang/lib/Analysis/FlowSensitive/Formula.cpp#L60 etc.

https://github.com/llvm/llvm-project/pull/95903


More information about the llvm-commits mailing list