[all-commits] [llvm/llvm-project] be1728: [CIR] Add support for the IdiomRecognizer pass (#2...
Rithik Sharma via All-commits
all-commits at lists.llvm.org
Thu Jul 16 09:56:14 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: be1728c99d806654d4ce4e7ad17aa89885e8053c
https://github.com/llvm/llvm-project/commit/be1728c99d806654d4ce4e7ad17aa89885e8053c
Author: Rithik Sharma <rithiksh02 at gmail.com>
Date: 2026-07-16 (Thu, 16 Jul 2026)
Changed paths:
M clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
M clang/include/clang/CIR/Dialect/IR/CIROps.td
A clang/include/clang/CIR/Dialect/IR/CIRStdOps.td
M clang/include/clang/CIR/Dialect/Passes.h
M clang/lib/CIR/CodeGen/CIRGenClass.cpp
M clang/lib/CIR/CodeGen/CIRGenFunction.cpp
M clang/lib/CIR/CodeGen/CIRGenModule.cpp
M clang/lib/CIR/CodeGen/CIRGenModule.h
M clang/lib/CIR/Dialect/IR/CIRDialect.cpp
M clang/lib/CIR/Dialect/Transforms/IdiomRecognizer.cpp
M clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
M clang/lib/CIR/Lowering/CIRPasses.cpp
A clang/test/CIR/CodeGen/func-identity-attr.c
A clang/test/CIR/CodeGen/func-identity-attr.cpp
A clang/test/CIR/IR/func-identity-attr.cir
A clang/test/CIR/Transforms/idiom-recognizer-guards-void-result.cpp
A clang/test/CIR/Transforms/idiom-recognizer-guards.cpp
A clang/test/CIR/Transforms/idiom-recognizer-inline-namespace.cpp
A clang/test/CIR/Transforms/idiom-recognizer.cir
M clang/test/CIR/Transforms/idiom-recognizer.cpp
M clang/tools/cir-opt/cir-opt.cpp
Log Message:
-----------
[CIR] Add support for the IdiomRecognizer pass (#208854)
This patch adds the `IdiomRecognizer` pass, which raises calls to known
standard library functions into dedicated operations that later passes
can optimize. The implementation follows the ClangIR incubator, and
upstream had only the pass skeleton and the frontend wiring.
The pass recognizes the standard find algorithm and raises it to the new
operation `cir.std.find`. A call is raised when its callee carries the
matching identity tag, the argument count and the types line up, the
callee is not variadic, and the call is not `musttail`. LoweringPrepare
lowers the operation back to the original call with its attributes, so
behavior never changes when no transform fires.
The tag is the new `func_identity` form under the `func_info` union on
`cir.func`. It holds one entry from an enum naming the entities the
recognizer knows, so the tag itself carries no names. `CIRGen` attaches
it by the plain name, the std membership with inline namespaces looked
through, and whether the function is free, so members, static members,
operators, and functions outside std never match, while the recognizer
checks the shape of each call.
The pass reads facts from the operations alone, so the AST requirement
and its wiring are gone, the pass is registered with `cir-opt`, and a
test drives it over parsed CIR assembly.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list