[LLVMdev] Pointer aliasing

Umesh Kalappa umesh.kalappa0 at gmail.com
Tue Jan 31 06:45:34 PST 2012


Hi Dan and Others  ,

I'm newbie to LLVM and Clang ,But has experience on compiler optimization
and  VM .
Everyone talking about the  LLVM in my organisation so thought of peeking
into it  and where this discussion is  stalled me ...

so  i  tried to simulate the problem ,which is discussed here .
vi sample.c

double f(double** p )
{
  double a,b,c;
  double * x = &a;
  double * y = &b;
  double * z = &c;

  *x = 1;
  *y = *x + 2;
  *z = *x + 3;

  return *x+*y+*z;
}

double ff(double** p )
{
  double a,b,c;
  double * x = &a;
  double * y = &b;
  double * z = &c;

  *x = 1;
  *y = *x + 2;
  *z = *x + 3;

  return *x+*y+*z;
}

compiled the sample.c .i.e  clang sample.c -S  -O3 -emit-llvm
cat sample.s

target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32"
target triple = "i386-pc-cygwin"

define double @f(double** nocapture %p) nounwind readnone {
  ret double 8.000000e+00
}

define double @ff(double** nocapture %p) nounwind readnone {
  ret double 8.000000e+00
}

Boom ...BasicAA or TBAA is  doing what it suppose to do :) for restrict
qualifier too..

Any lights on this ???

FYI , $ lli --version
Low Level Virtual Machine (http://llvm.org/):
 llvm version 3.0
 Optimized build.
 Built Jan 24 2012 (05:48:10).
 Host: i386-pc-cygwin
 Host CPU: penryn

Thanks
~Umesh


On Fri, Jan 27, 2012 at 12:37 AM, Dan Gohman <gohman at apple.com> wrote:

> On Jan 24, 2012, at 8:58 PM, Brent Walker wrote:
>
> > Thank you for your reply.  The compromise you describe below, is it a
> > compromise in the LLVM back end or in clang?  I run into this while
> > building a compiler for a small DSL language for which I generate
> > functions that receive a context from which they extract a bunch of
> > pointers to doubles from which inputs are passed to the function (I
> > just used C/clang in my examples to illustrate the problem).
>
> For restrict-style alias information, the limitation is in LLVM.
>
> Since you're not using clang, you might be able to use a custom TBAA
> type tree instead. TBAA works differently from restrict; it applies
> to loads and stores, rather than to pointers. But if you can frame
> your aliasing property as a type-oriented property, saying for
> example that each array element is a pointer to a distinct type, it
> may suffice.
>
> Dan
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120131/707295d4/attachment.html>


More information about the llvm-dev mailing list