================
@@ -10253,3 +10253,52 @@ The attribute is also supported with blocks and in
Objective-C.
}
}];
}
+
+def ConstDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
+The ``const`` attribute can be applied to the declaration of a function to
signal that repeated calls to the function with the same argument values may be
safe to elide because the subsequent calls will always return the same value as
the initial call.
+
+The attribute informs the optimizer that the function cannot read or write to
memory, does not support unwinding, will return (has no infinite loops), and
that any pointer or reference arguments to the call will not be read from or
written to.
----------------
AaronBallman wrote:
> Really? Not reading from pointer/reference args? That seems... dumb. Why
> would you even HAVE them?
If you have a pointer or reference argument, you'd use `pure` instead of
`const`, basically. But I think the idea here is: if you have a pointer or
reference, then something outside of the function could change what's being
pointed to, so you may get different results if you elide the call.
> Also, does this apply to values derived from arguments?
Not certain I understand the question. Code example?
https://github.com/llvm/llvm-project/pull/205881
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits