[Mlir-commits] [mlir] [mlir][LLVM] Add the `ConvertToLLVMAttrInterface` and `ConvertToLLVMOpInterface` interfaces (PR #99566)

Fabian Mora llvmlistbot at llvm.org
Fri Jul 26 14:59:41 PDT 2024


================
@@ -104,20 +99,33 @@ class ConvertToLLVMPass
         auto *iface = dyn_cast<ConvertToLLVMPatternInterface>(dialect);
         if (!iface)
           continue;
-        iface->populateConvertToLLVMConversionPatterns(*target, *typeConverter,
-                                                       tempPatterns);
+        interfaces->push_back(iface);
       }
     }
 
-    this->patterns =
-        std::make_unique<FrozenRewritePatternSet>(std::move(tempPatterns));
-    this->target = target;
-    this->typeConverter = typeConverter;
+    this->interfaces = interfaces;
     return success();
   }
 
   void runOnOperation() final {
-    if (failed(applyPartialConversion(getOperation(), *target, *patterns)))
+    MLIRContext *context = &getContext();
+    RewritePatternSet patterns(context);
+    ConversionTarget target(*context);
+    target.addLegalDialect<LLVM::LLVMDialect>();
+    LLVMTypeConverter typeConverter(context);
----------------
fabianmcg wrote:

Test results:
LLVM Release with assertions off 
cpu: Intel(R) Xeon(R) Gold 6132 CPU @ 2.60GHz
Test: run 100 times `mlir-opt --pass-pipeline="builtin.module(convert-to-llvm)"  mlir/test/Conversion/FuncToLLVM/func-to-llvm.mlir --mlir-timing` 

convert-to-llvm time:
```
Pre change: 0.00210028567 s
Post change: 0.0019316432 s
Difference: 0.00016864247 s
Slowdown(post/pre): 1.08730518658932
```

Total time:
```
Pre change: 0.00816961453 s
Post change: 0.00827812259 s
Difference: 0.00010850806 s
Slowdown(post/pre): 1.01328190694941
```

Globally the impact seems to be minimal (less than 2%), per pass it seems to increase around 10%. However, the per pass time doesn't include initialization.


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


More information about the Mlir-commits mailing list