Hi All
I am writing a pass which requires checking dependences, and am having trouble dealing with function calls. Specifically, I want to be able to know when a called function does not have any side effects (e.g. math library functions like sqrt), and was wondering if there are attributes that specify this behavior (I know there is the ‘noread’ attribute but wasn’t sure if there’s something similar for writes)? Also, how can I tell clang to generate those attributes at the function declaration? Any information would be helpful.
Thanks
-Adel Ejjeh
Specifically, I want to be able to know when a called function does not have any side effects (e.g. math library functions like sqrt)
, and was wondering if there are attributes that specify this behavior (I know there is the ‘noread’ attribute but wasn’t sure if there’s something similar for writes)? Also, how can I tell clang to generate those attributes at the function declaration? Any information would be helpful.
Often true. In case of library functions we actually "know" the side
effects and will add the appropriate attributes. As you said, fast math
flags are needed for math library functions that may otherwise write
errno.
The full list of attributes we have so far is:
access locations: `readnone`, `inaccessiblememonly`, `argmemonly`,
and `inaccessiblemem_or_argmemonly`
and access "kinds": `readonly` and `writeonly`
Except for `readnone` you can combine a location attribute with a "kind"
or have one of either alone. The Attributor does internally derive more
"locations", basically any combination of:
local memory
constant memory
internal global memory
external global memory
argument memory
inaccessible memory
malloced memory (returned by a function with the `noalias` return
attribute)
unknown memory
I want to add some/all of these as attributes but didn't find the time
yet.
Cheers,
Johannes
>
> HTH
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Michael
Am Do., 30. Apr. 2020 um 10:46 Uhr schrieb Alexey Zhikhartsev via
llvm-dev <llvm...@lists.llvm.org>:
-fno-builtin-<value> Disable implicit builtin knowledge of a
specific function
-fno-builtin Disable implicit builtin knowledge of functions
Hello Neil
Thanks for your reply. After experimenting in the Compiler Explorer, it seems that the “readnone” attribute is assigned for functions that neither read from nor write to memory (otherwise “readonly” or “writeonly” are used accordingly when the function does one but not the other). However, one of my problems still exists which is using library function calls (like math library calls – e.g. sqrt()). When the declaration for such functions is being generated in the ll file, it does not include any attributes. Is there a way to handle such scenario?
Thanks
-Adel
From: Neil Henning <neil.h...@unity3d.com>
Date: Wednesday, April 29, 2020 at 4:22 AM
To: "Ejjeh, Adel" <aej...@illinois.edu>
Subject: Re: [llvm-dev] Function attributes for memory side-effects
Hey Adel Ejjeh,
You want to look at the LLVM function attributes readnone and maybe readonly to know that a function has no side effects.
You can use the __attribute__((pure)) from clang to force this on functions I believe (see https://godbolt.org/z/dqBMjE for an example).
Cheers,
-Neil.
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev