[clang] [CIR] Rewrite a raised std::find over bytes into memchr (PR #212355)

Rithik Sharma via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 13 10:00:28 PDT 2026


================
@@ -1522,11 +1527,12 @@ def CIR_FuncIdentityAttr : CIR_Attr<"FuncIdentity", "func_identity"> {
   }];
 
   let parameters = (ins
-    EnumParameter<CIR_KnownFuncKind>:$kind
+    EnumParameter<CIR_KnownFuncKind>:$kind,
+    DefaultValuedParameter<"bool", "false">:$narrow_char_params
----------------
SharmaRithik wrote:

Thanks Erich! I started thinking about this yesterday while working on follow up support for the `wchar_t case` of `std::find to wmemchr`. Adding another boolean next to `narrow_char_params` did expose the same problem.

Also this check is not part of the function identity, and CIRGen still knows the source parameter types when it emits a direct call.  One option I was thinking of is recording the check on that call, and the recognizer can carry it to `cir.std.find`, and `LibOpt` can read it there, which makes it keep the FuncIdentityAttr limited to `kind`.

@andykaylor, what do you think about this direction?

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


More information about the cfe-commits mailing list