Skip to content

[CIR][CodeGen] Use MapVector instead of StringMap for replacements#181969

Merged
andykaylor merged 1 commit intollvm:mainfrom
xaerru:stringmap-to-mapvector
Feb 18, 2026
Merged

[CIR][CodeGen] Use MapVector instead of StringMap for replacements#181969
andykaylor merged 1 commit intollvm:mainfrom
xaerru:stringmap-to-mapvector

Conversation

@xaerru
Copy link
Copy Markdown
Contributor

@xaerru xaerru commented Feb 18, 2026

Upstreaming llvm/clangir#2116

@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels Feb 18, 2026
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Feb 18, 2026

@llvm/pr-subscribers-clangir

@llvm/pr-subscribers-clang

Author: Gauravsingh Sisodia (xaerru)

Changes

Upstreaming llvm/clangir#2116


Full diff: https://github.com/llvm/llvm-project/pull/181969.diff

2 Files Affected:

  • (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+1-1)
  • (modified) clang/lib/CIR/CodeGen/CIRGenModule.h (+1-2)
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 5eda2e1398fad..dbd3c92797f23 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -1163,7 +1163,7 @@ void CIRGenModule::replacePointerTypeArgs(cir::FuncOp oldF, cir::FuncOp newF) {
 
 void CIRGenModule::applyReplacements() {
   for (auto &i : replacements) {
-    StringRef mangledName = i.first();
+    StringRef mangledName = i.first;
     mlir::Operation *replacement = i.second;
     mlir::Operation *entry = getGlobalValue(mangledName);
     if (!entry)
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.h b/clang/lib/CIR/CodeGen/CIRGenModule.h
index b4c1d3a10e470..5b8a105e4912f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.h
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.h
@@ -730,8 +730,7 @@ class CIRGenModule : public CIRGenTypeCache {
   llvm::StringMap<clang::GlobalDecl, llvm::BumpPtrAllocator> manglings;
 
   // FIXME: should we use llvm::TrackingVH<mlir::Operation> here?
-  typedef llvm::StringMap<mlir::Operation *> ReplacementsTy;
-  ReplacementsTy replacements;
+  llvm::MapVector<StringRef, mlir::Operation *> replacements;
   /// Call replaceAllUsesWith on all pairs in replacements.
   void applyReplacements();
 

Copy link
Copy Markdown
Contributor

@andykaylor andykaylor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Can you copy the description from llvm/clangir#2116 into this PR? It will be useful in the commit history.

When using llvm::StringMap transitive replacements may be out of order.
So use llvm::MapVector which is also used in clang's CodeGen.
@xaerru xaerru force-pushed the stringmap-to-mapvector branch from ccbf70d to ac4ceb3 Compare February 18, 2026 18:44
@xaerru xaerru requested a review from andykaylor February 18, 2026 19:02
@andykaylor andykaylor merged commit 14b213f into llvm:main Feb 18, 2026
10 checks passed
@xaerru xaerru deleted the stringmap-to-mapvector branch February 19, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants