[llvm] [GlobalISel] Cache split LLTs in IRTranslator (PR #195267)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Sun May 3 07:10:23 PDT 2026
================
@@ -127,19 +138,29 @@ class IRTranslator : public MachineFunctionPass {
}
OffsetListT *insertOffsets(const Value &V) {
- assert(!TypeToOffsets.contains(V.getType()) && "Type already exists");
-
auto *OffsetList = new (OffsetAlloc.Allocate()) OffsetListT();
- TypeToOffsets[V.getType()] = OffsetList;
- return OffsetList;
+ auto [It, Inserted] = TypeToOffsets.insert({V.getType(), OffsetList});
+ if (!Inserted)
+ llvm_unreachable("Type already exists");
+ return It->second;
+ }
+
+ SplitTypeListT *insertSplitTys(const Value &V) {
+ auto *SplitTyList = new (SplitTyAlloc.Allocate()) SplitTypeListT();
+ auto [It, Inserted] = TypeToSplitTys.insert({V.getType(), SplitTyList});
+ if (!Inserted)
+ llvm_unreachable("Type already exists");
+ return It->second;
}
SpecificBumpPtrAllocator<VRegListT> VRegAlloc;
SpecificBumpPtrAllocator<OffsetListT> OffsetAlloc;
+ SpecificBumpPtrAllocator<SplitTypeListT> SplitTyAlloc;
// We store pointers to vectors here since references may be invalidated
// while we hold them if we stored the vectors directly.
DenseMap<const Value *, VRegListT*> ValToVRegs;
DenseMap<const Type *, OffsetListT*> TypeToOffsets;
+ DenseMap<const Type *, SplitTypeListT *> TypeToSplitTys;
----------------
aengelke wrote:
Couldn't we use a single hash map for offsets+split tys?
https://github.com/llvm/llvm-project/pull/195267
More information about the llvm-commits
mailing list