[Mlir-commits] [mlir] [mlir][ODS] Copy constant generated interface model prototypes (PR #226323)
Mehdi Amini
llvmlistbot at llvm.org
Mon Sep 28 05:51:02 PDT 2026
================
@@ -228,9 +239,19 @@ class InterfaceMap {
// static_assert(std::is_trivially_destructible_v<InterfaceModel>,
// "interface models must be trivially destructible");
- // Build the interface model, optionally initializing if necessary.
- InterfaceModel *model =
- new (malloc(sizeof(InterfaceModel))) InterfaceModel();
+ // Generated models contain a fixed table of callbacks. Copy a constant
+ // prototype so the callbacks need not be set up for each model.
+ InterfaceModel *model;
+ if constexpr (IsConstexprGeneratedModel<InterfaceModel>::value) {
+ static constexpr InterfaceModel prototype;
+ model = new (malloc(sizeof(InterfaceModel))) InterfaceModel(prototype);
----------------
joker-eph wrote:
FYI: This is the fast-path here, this invokes the constexpr ctor followed by copy init instead of the default ctor in the else branch.
https://github.com/llvm/llvm-project/pull/226323
More information about the Mlir-commits
mailing list