[LLVMdev] c const

Duncan Sands baldrick at free.fr
Sun Aug 19 12:41:42 PDT 2007


Hi Christopher,

On Friday 17 August 2007 19:42:31 Christopher Lamb wrote:
> On Aug 16, 2007, at 9:09 AM, Chris Lattner wrote:
> > On Thu, 16 Aug 2007, Holger Schurig wrote:
> >>> if the programmer is going to tell you that the memory pointed
> >>> to by a pointer argument is never written.
> 
> If you use a const * __restrict pointer then you should get the  
> benefit of this as the alias analysis will assume that the pointed to  
> object is neither aliased nor written.

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.

Thanks,

Duncan.



More information about the llvm-dev mailing list