================
@@ -4089,6 +4089,48 @@ def CIR_PrefetchOp : CIR_Op<"prefetch"> {
     }];
 }
 
+//===----------------------------------------------------------------------===//
+// ObjSizeOp
+//===----------------------------------------------------------------------===//
+
+def CIR_ObjSizeOp : CIR_Op<"objsize", [Pure]> {
+  let summary = "Implements the llvm.objsize builtin";
+  let description = [{
+    The `cir.objsize` operation models the behavior of the `llvm.objectsize`
+    intrinsic in Clang. It returns the number of accessible bytes past ptr.
----------------
andykaylor wrote:

```suggestion
    The `cir.objsize` operation is designed to provide information to the
    optimizer to determine whether a) an operation (like memcpy) will
    overflow a buffer that corresponds to an object, or b) that a runtime
    check for overflow isn’t necessary. An object in this context means an
    allocation of a specific class, structure, array, or other object.
```
This is directly copied from the LLVM Language Reference description of the 
`llvm.objectsize` intrinsic. I found "the `llvm.objectsize` intrinsic in Clang" 
to be unclear. The second statement was generally inaccurate, given that this 
may return 0 or -1, as described below.

https://github.com/llvm/llvm-project/pull/166191
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to