[LLVMdev] Readnone/Readonly Function Attributes and Optimization
Owen Anderson
resistor at mac.com
Wed Jun 20 16:33:55 PDT 2012
John,
On Jun 20, 2012, at 2:26 PM, John Criswell <criswell at illinois.edu> wrote:
> Dear All,
>
> Are functions marked as readnone or readonly in the LLVM IR allowed to
> generate output or to exhibit exceptional behavior (e.g., calling
> abort(), generating an MMU fault, etc.)?
>
> The SAFECode compiler has a set of run-time checks that pass or fail
> based solely on the input arguments and, in some cases, global state.
> They do not modify a program's global state, but they do print output on
> failures and can abort the program. I'm wondering if adding the
> readnone/readonly attributes to these run-time checks is safe.
This depends a little bit on the details of your use case. LLVM will freely CSE or DCE calls marked readnone. If that's acceptable to you, you can lie and apply the attribute, but don't be surprised when it optimizes away one of those calls.
--Owen
More information about the llvm-dev
mailing list