[llvm-dev] [RFC] Adding a globalmemonly attribute for functions that only access global memory

Philip Reames via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 14 12:17:14 PDT 2021


On 9/14/21 11:27 AM, James Y Knight wrote:
> On Tue, Sep 14, 2021 at 2:03 PM Philip Reames via llvm-dev 
> <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>
>     In fact, the original motivation for the globalmemonly proposal
>     could be
>     alternatively solved with:
>
>     @errno = external global i32
>
>     declare void @mathfunc(float, float) globalmayalias(@errno)
>
>
> How would that work, since errno generally isn't a global (or a 
> compiler-supported thread-local)? It's typically something along the 
> lines of:
>   int* __errno_location(void) __attribute__((const));
>   #define errno *__errno_location()

Didn't actually know that.  Johannes point about consistent lies does 
apply, but I hadn't had that in mind when I wrote this.  We might also 
be able to play games with constexpr-like functions being "similar" to 
globals, but honestly, I'd probably just take a different approach for 
this particular problem.  Like, say, the original RFC in this thread.

Philip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210914/8484ccec/attachment.html>


More information about the llvm-dev mailing list