[Mlir-commits] [mlir] [mlir] Speed up FuncToLLVM: CallOpLowering using SymbolTableCollection (PR #68082)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Oct 3 02:15:55 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

<details>
<summary>Changes</summary>

We have a project where this saves 23% of the compilation time.

This means using hashmaps instead of searching in linked lists.

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


1 Files Affected:

- (modified) mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp (+6-2) 


``````````diff
diff --git a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
index 7de7f3cb9e36b06..b853181c618365d 100644
--- a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
+++ b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
@@ -601,19 +601,23 @@ struct CallOpInterfaceLowering : public ConvertOpToLLVMPattern<CallOpType> {
   }
 };
 
-struct CallOpLowering : public CallOpInterfaceLowering<func::CallOp> {
+class CallOpLowering : public CallOpInterfaceLowering<func::CallOp> {
+public:
   using Super::Super;
 
   LogicalResult
   matchAndRewrite(func::CallOp callOp, OpAdaptor adaptor,
                   ConversionPatternRewriter &rewriter) const override {
     bool useBarePtrCallConv = false;
-    if (Operation *callee = SymbolTable::lookupNearestSymbolFrom(
+    if (Operation *callee = symbolTableCollection.lookupNearestSymbolFrom(
             callOp, callOp.getCalleeAttr())) {
       useBarePtrCallConv = shouldUseBarePtrCallConv(callee, getTypeConverter());
     }
     return matchAndRewriteImpl(callOp, adaptor, rewriter, useBarePtrCallConv);
   }
+
+private:
+  mutable SymbolTableCollection symbolTableCollection;
 };
 
 struct CallIndirectOpLowering

``````````

</details>


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


More information about the Mlir-commits mailing list