[CIR][CodeGen] Use MapVector instead of StringMap for replacements#181969
Merged
andykaylor merged 1 commit intollvm:mainfrom Feb 18, 2026
Merged
[CIR][CodeGen] Use MapVector instead of StringMap for replacements#181969andykaylor merged 1 commit intollvm:mainfrom
andykaylor merged 1 commit intollvm:mainfrom
Conversation
Member
|
@llvm/pr-subscribers-clangir @llvm/pr-subscribers-clang Author: Gauravsingh Sisodia (xaerru) ChangesUpstreaming llvm/clangir#2116 Full diff: https://github.com/llvm/llvm-project/pull/181969.diff 2 Files Affected:
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();
|
andykaylor
approved these changes
Feb 18, 2026
Contributor
andykaylor
left a comment
There was a problem hiding this comment.
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.
ccbf70d to
ac4ceb3
Compare
andykaylor
approved these changes
Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstreaming llvm/clangir#2116