[clang] [CIR] Add support for the IdiomRecognizer pass (PR #208854)

Rithik Sharma via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 13 21:00:52 PDT 2026


================
@@ -1296,11 +1296,52 @@ def CIR_CXXAssignAttr : CIR_Attr<"CXXAssign", "cxx_assign"> {
 // FuncInfoAttr
 //===----------------------------------------------------------------------===//
 
+// The standard library entities the identity tag can name. Each entry
+// pairs with one raised operation in CIRStdOps.td.
+def CIR_KnownFuncKind : CIR_I32EnumAttr<"KnownFuncKind",
+    "known standard library entity", [
+  I32EnumAttrCase<"StdFind", 1, "std_find">,
+]> {
+  let genSpecializedAttr = 0;
+}
+
+def CIR_FuncIdentityAttr : CIR_Attr<"FuncIdentity", "func_identity"> {
+  let summary = "Identifies a function as a known standard library entity";
+  let description = [{
+    Names the standard library entity a function represents, so that
+    transformations can recognize calls to well known library functions
+    without decoding mangled symbol names.
+
+    The tag names the whole entity. For `std_find` that is the free
+    function named `find` in the `std` namespace, so a member function, a
+    static member, or an operator can never carry the tag. Inline
+    namespaces, such as the versioning namespace of libc++, count as part
+    of `std`. The tag never encodes signatures, and a function that
+    matches no known entity carries no attribute.
+
+    Example:
+    ```
+    #cir.func_identity<std_find>
+    ```
+  }];
+
+  let parameters = (ins
+    EnumParameter<CIR_KnownFuncKind>:$kind
----------------
SharmaRithik wrote:

Agreed, that is the right long term shape, member push_back with the container and its primary template argument recorded. Nothing here needs it, so the class enum is a clean add when the first member idiom lands.

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


More information about the cfe-commits mailing list