llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clangir

Author: Bruno Cardoso Lopes (bcardosolopes)

<details>
<summary>Changes</summary>

CIRGenBuilderTy carries two StringMaps by value (record name and global 
versioning maps), which grow to tens of thousands of entries over a translation 
unit. getVTableComponent copied the builder on every call, deep-copying both 
maps per vtable component: quadratic work that cost ~12.5s while selfhosting 
clang/unittests/AST/ASTImporterTest.cpp.

Take the builder by reference instead, matching every other call site. Also 
take it by reference in genVscaleTimesFactor, the only other by-value use.

ASTImporterTest -fclangir wall time goes from 87.4s to 75.0s; output is 
unchanged.

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


2 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp (+1-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenVTables.cpp (+1-1) 


``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
index ba7355cffbaf0..30438d5288608 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
@@ -37,7 +37,7 @@ using namespace clang::aarch64;
 
 // Generate vscale * scalingFactor
 static mlir::Value genVscaleTimesFactor(mlir::Location loc,
-                                        CIRGenBuilderTy builder,
+                                        CIRGenBuilderTy &builder,
                                         mlir::Type cirTy,
                                         int32_t scalingFactor) {
   mlir::Value vscale = builder.emitIntrinsicCallOp(loc, "vscale", cirTy);
diff --git a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp 
b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp
index 270b8a6a539ba..ca7a8a74a9e21 100644
--- a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp
@@ -141,7 +141,7 @@ mlir::Attribute CIRGenVTables::getVTableComponent(
     bool vtableHasLocalLinkage) {
   const VTableComponent &component = 
layout.vtable_components()[componentIndex];
 
-  CIRGenBuilderTy builder = cgm.getBuilder();
+  CIRGenBuilderTy &builder = cgm.getBuilder();
 
   assert(!cir::MissingFeatures::vtableRelativeLayout());
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/232509
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to