[Mlir-commits] [mlir] [mlir] Speed up FuncToLLVM: CallOpLowering using a hashtable (PR #68082)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Oct 4 01:52:34 PDT 2023
================
@@ -601,19 +602,37 @@ struct CallOpInterfaceLowering : public ConvertOpToLLVMPattern<CallOpType> {
}
};
-struct CallOpLowering : public CallOpInterfaceLowering<func::CallOp> {
- using Super::Super;
+class CallOpLowering : public CallOpInterfaceLowering<func::CallOp> {
+public:
+ CallOpLowering(const LLVMTypeConverter &typeConverter,
+ // Can be nullptr.
+ const StringSet<> *functionsHavingBarePtrAttribute,
+ PatternBenefit benefit = 1)
+ : CallOpInterfaceLowering<func::CallOp>(typeConverter, benefit),
+ barePtrCallConvForcedByOptions(
+ typeConverter.getOptions().useBarePtrCallConv),
+ functionsHavingBarePtrAttribute(functionsHavingBarePtrAttribute) {}
LogicalResult
matchAndRewrite(func::CallOp callOp, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
bool useBarePtrCallConv = false;
- if (Operation *callee = SymbolTable::lookupNearestSymbolFrom(
+ if (barePtrCallConvForcedByOptions) {
+ useBarePtrCallConv = true;
+ } else if (functionsHavingBarePtrAttribute != nullptr) {
+ useBarePtrCallConv = functionsHavingBarePtrAttribute->contains(
+ callOp.getCalleeAttr().getValue());
+ } else if ( // Warning: This is a linear lookup.
+ Operation *callee = SymbolTable::lookupNearestSymbolFrom(
callOp, callOp.getCalleeAttr())) {
----------------
tdanyluk wrote:
It looks like the SymbolTable approach actually works if we construct the SymbolTable before the patterns are applied.
My earlier approach didn't work because I created the SymbolTable during the rewrite.
https://github.com/llvm/llvm-project/pull/68082
More information about the Mlir-commits
mailing list