[clang] [CIR] Memoize FuncType purity checks in the CIR dialect (PR #232863)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 16 10:59:02 PDT 2026


================
@@ -147,6 +147,14 @@ def CIR_Dialect : Dialect {
     mlir::Type parseType(mlir::DialectAsmParser &parser) const override;
     void printType(mlir::Type type,
                    mlir::DialectAsmPrinter &printer) const override;
+
+    /// Returns true if \p ty and every type nested in it are CIR types.
+    /// Memoized, since FuncType verification re-queries the same records.
+    bool isPureCIRType(mlir::Type ty) const;
+
+  private:
+    mutable llvm::DenseMap<mlir::Type, bool> pureCIRTypeCache;
+    mutable std::mutex pureCIRTypeCacheMutex;
----------------
erichkeane wrote:

Hmm... ClangIR hasn't really been doing thread-safety yet, right?  I guess I see the value, but we probably need to spend time figuring out how we're going to do everything else thread-safe.

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


More information about the cfe-commits mailing list