[LLVMdev] Minimum Array Size
Hal Finkel
hfinkel at anl.gov
Mon Sep 10 19:34:47 PDT 2012
On Mon, 10 Sep 2012 17:40:43 -0700
Nick Lewycky <nicholas at mxc.ca> wrote:
> Hal Finkel wrote:
> > Hello,
> >
> > clang currently seems to generate the same code for both:
> >
> > double something_a(char A[const static 256]) {
> > ...
> > }
> >
> > and for:
> >
> > double something_b(char (*const A)) {
> > ...
> > }
> >
> > even though in the first case the programmer has told us that the
> > array A is at least 256 bytes in length (and, thus, will not be
> > null). Do we currently have a way to pass this information to LLVM?
>
> No, but I'm interested in this. C++ references imply that 'n' bytes
> of the pointer may be dereferenced, and we have no way of capturing
> that fact. It would feed into llvm::isSafeToLoadUnconditionally().
At the risk of starting yet another metadata proposal discussion, shall
we add some metadata to describe this? These cases could be handled by
metadata with an integer parameter. Is there a reasonable way of
handling cases like:
void foo(int n, int q[n][n]) { ... } ?
-Hal
>
> Nick
--
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-dev
mailing list