================
@@ -45,9 +45,41 @@ template <> bool signatureMatches<StdFindOp>(CallOp call) {
iterTy == call->getResult(0).getType();
}
-// Raises a direct cir.call to `TargetOp` when the callee carries the
-// matching identity tag.
-template <typename TargetOp> class StdRecognizer {
+// strlen takes a pointer to an 8 bit character and returns size_t, an unsigned
+// fundamental integer. A _BitInt is not a character type even at width 8.
+template <> bool signatureMatches<StrLenOp>(CallOp call) {
+ if (call.getNumOperands() != StrLenOp::getNumArgs() ||
+ call->getNumResults() != 1)
+ return false;
+ auto ptrTy = mlir::dyn_cast<cir::PointerType>(call.getOperand(0).getType());
+ return ptrTy && cir::isChar8Type(ptrTy.getPointee()) &&
+ cir::isFundamentalUIntType(call->getResult(0).getType());
+}
+
+// Returns true when the recorded no builtin state forbids treating the call
+// as the C library function `name`. The call carries a nobuiltin mark and
+// the caller a nobuiltins list, where an empty list disables them all.
+bool isNoBuiltin(CallOp call, llvm::StringRef name) {
+ if (call->hasAttr(cir::CIRDialect::getNoBuiltinAttrName()))
----------------
andykaylor wrote:
I don't think it applies to strlen, but in the general case we also need to
verify that the call doesn't have the "builtin" attribute set. The front end
sets both "nobuiltin" and "builtin" when a replaceable global allocation
function is called but the `-fno-builtin` option was used.
https://github.com/llvm/llvm-project/pull/210400
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits