On Aug 19, 2007, at 1:15 PM, Gordon Henriksen wrote:
> On 2007-08-19, at 15:41, Duncan Sands wrote:
>
>> can you please explain more about what restrict means: it may help
>> in improving code quality for Ada. In Ada you have runtime
>> constants that are really constant, for example array bounds. The
>> bounds are passed around by pointer, which causes LLVM to think
>> they may be aliased and changed by function calls (which is
>> impossible). This results on rotten code since (for example) the
>> array length and bounds checks are recalculated again and again
>> when one calculation would do. [The front-end outputs a bound
>> check for every array access, expecting the optimizers to remove
>> redundant checks, which LLVM often does not do]. If I could teach
>> LLVM that array bounds are really constant that would presumably
>> solve the problem.
The benefits of a const * __restrict come from two different places.
The const part is essentially enforced by the front-end and the
restrict part is used to inform the alias analysis (it becomes a
noalias parameter attribute). The noalias parameter attribute may be
of use to you eventually, but full noalias implementation isn't yet
complete. Specifically the case where a function with noalias
parameter attributes is inlined does not currently preserve the
noalias information.
> Here's a thread about it:
>
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-March/thread.html#8291
You should also take a look at PR 1373, as that is where progress is
being tracked. http://llvm.org/bugs/show_bug.cgi?id=1373
> I don't think anything has been implemented.
Per the discussion and PR there has been work done to implement the
'noalias' parameter attribute in LLVM, and currently BasicAA will use
this attribute to inform alias queries that are made. There has also
been work to map __restrict C/C++ pointer and reference parameters
onto the noalias parameter attribute. There is still much work to be
done to fully implement noalias in LLVM, notably the intrinsic and
updates to tolerate/use it, as well as to fully support all uses of
the __restrict qualifier in the C/C++ front end.
--
Christopher Lamb
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20070819/03241375/attachment.html>