diff --git a/llvm/include/llvm/Support/TypeName.h b/llvm/include/llvm/Support/TypeName.h --- a/llvm/include/llvm/Support/TypeName.h +++ b/llvm/include/llvm/Support/TypeName.h @@ -24,7 +24,7 @@ /// However, it may not be null terminated and may be some strangely aligned /// inner substring of a larger string. template -inline StringRef getTypeName() { +LLVM_ATTRIBUTE_NOINLINE StringRef getTypeName() { #if defined(__clang__) || defined(__GNUC__) StringRef Name = __PRETTY_FUNCTION__; diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -466,7 +466,8 @@ private: /// Helper for sanity checking preconditions for create* methods below. template - RegisteredOperationName getCheckRegisteredInfo(MLIRContext *ctx) { + LLVM_ATTRIBUTE_NOINLINE RegisteredOperationName + getCheckRegisteredInfo(MLIRContext *ctx) { std::optional opName = RegisteredOperationName::lookup(OpT::getOperationName(), ctx); if (LLVM_UNLIKELY(!opName)) { diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h --- a/mlir/include/mlir/IR/Diagnostics.h +++ b/mlir/include/mlir/IR/Diagnostics.h @@ -177,14 +177,14 @@ std::enable_if_t::value && std::is_constructible::value, Diagnostic &> - operator<<(Arg &&val) { + LLVM_ATTRIBUTE_NOINLINE operator<<(Arg &&val) { arguments.push_back(DiagnosticArgument(std::forward(val))); return *this; } Diagnostic &operator<<(StringAttr val); /// Stream in a string literal. - Diagnostic &operator<<(const char *val) { + LLVM_ATTRIBUTE_NOINLINE Diagnostic &operator<<(const char *val) { arguments.push_back(DiagnosticArgument(val)); return *this; } @@ -225,7 +225,8 @@ /// Append arguments to the diagnostic. template - Diagnostic &append(Arg1 &&arg1, Arg2 &&arg2, Args &&...args) { + LLVM_ATTRIBUTE_NOINLINE Diagnostic &append(Arg1 &&arg1, Arg2 &&arg2, + Args &&...args) { append(std::forward(arg1)); return append(std::forward(arg2), std::forward(args)...); } diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -105,11 +105,16 @@ public: Impl(StringRef, Dialect *dialect, TypeID typeID, detail::InterfaceMap interfaceMap); + + LLVM_ATTRIBUTE_NOINLINE Impl(StringAttr name, Dialect *dialect, TypeID typeID, detail::InterfaceMap interfaceMap) : name(name), typeID(typeID), dialect(dialect), interfaceMap(std::move(interfaceMap)) {} + LLVM_ATTRIBUTE_NOINLINE + ~Impl() = default; + /// Returns true if this is a registered operation. bool isRegistered() const { return typeID != TypeID::get(); } detail::InterfaceMap &getInterfaceMap() { return interfaceMap; } @@ -387,15 +392,20 @@ Model(Dialect *dialect) : Impl(ConcreteOp::getOperationName(), dialect, TypeID::get(), ConcreteOp::getInterfaceMap()) {} - LogicalResult foldHook(Operation *op, ArrayRef attrs, - SmallVectorImpl &results) final { + LLVM_ATTRIBUTE_NOINLINE ~Model() = default; + + LLVM_ATTRIBUTE_NOINLINE LogicalResult + foldHook(Operation *op, ArrayRef attrs, + SmallVectorImpl &results) final { return ConcreteOp::getFoldHookFn()(op, attrs, results); } void getCanonicalizationPatterns(RewritePatternSet &set, MLIRContext *context) final { ConcreteOp::getCanonicalizationPatterns(set, context); } - bool hasTrait(TypeID id) final { return ConcreteOp::getHasTraitFn()(id); } + LLVM_ATTRIBUTE_NOINLINE bool hasTrait(TypeID id) final { + return ConcreteOp::getHasTraitFn()(id); + } OperationName::ParseAssemblyFn getParseAssemblyFn() final { return ConcreteOp::parse; } @@ -403,14 +413,16 @@ NamedAttrList &attrs) final { ConcreteOp::populateDefaultAttrs(name, attrs); } - void printAssembly(Operation *op, OpAsmPrinter &printer, - StringRef name) final { + LLVM_ATTRIBUTE_NOINLINE void + printAssembly(Operation *op, OpAsmPrinter &printer, StringRef name) final { ConcreteOp::getPrintAssemblyFn()(op, printer, name); } - LogicalResult verifyInvariants(Operation *op) final { + LLVM_ATTRIBUTE_NOINLINE LogicalResult + verifyInvariants(Operation *op) final { return ConcreteOp::getVerifyInvariantsFn()(op); } - LogicalResult verifyRegionInvariants(Operation *op) final { + LLVM_ATTRIBUTE_NOINLINE LogicalResult + verifyRegionInvariants(Operation *op) final { return ConcreteOp::getVerifyRegionInvariantsFn()(op); } }; @@ -695,6 +707,9 @@ SmallVector, 1> regions; public: + LLVM_ATTRIBUTE_NOINLINE OperationState() = default; + LLVM_ATTRIBUTE_NOINLINE ~OperationState() = default; + OperationState(Location location, StringRef name); OperationState(Location location, OperationName name); diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -1784,8 +1784,9 @@ /// Add an instance of the pattern type 'T'. Return a reference to `this` for /// chaining insertions. template - std::enable_if_t::value> - addImpl(ArrayRef debugLabels, Args &&...args) { + LLVM_ATTRIBUTE_NOINLINE + std::enable_if_t::value> + addImpl(ArrayRef debugLabels, Args &&...args) { std::unique_ptr pattern = RewritePattern::create(std::forward(args)...); pattern->addDebugLabels(debugLabels); diff --git a/mlir/include/mlir/Support/TypeID.h b/mlir/include/mlir/Support/TypeID.h --- a/mlir/include/mlir/Support/TypeID.h +++ b/mlir/include/mlir/Support/TypeID.h @@ -189,7 +189,7 @@ template using is_fully_resolved = llvm::is_detected; - static TypeID resolveTypeID() { + LLVM_ATTRIBUTE_NOINLINE static TypeID resolveTypeID() { static_assert(is_fully_resolved::value, "TypeID::get<> requires the complete definition of `T`"); static TypeID id = registerImplicitTypeID(llvm::getTypeName());