Eli, thanks for responding, unfortunately, this did not resolve my issue. It's a locally allocated array in the C code, but I'm not seeing any alloca in the IR just geps from the variable, which is never setup. On Wed, Aug 15, 2012 at 11:33 AM, Eli Friedman <eli.friedman at gmail.com>wrote:> On Wed, Aug 15, 2012 at 11:26 AM, Ryan Taylor <ryta1203 at gmail.com> wrote: > > I have a const array allocated inside a function and the IR is showing > this > > has a global function (ie. there is no allocation for the space inside > the > > function). > > > > For example: > > > > const int32 local_array[256] = {constValue, constValue, ..... } > > > > Is there any particular reason this may be occuring? > > It's an optimization; IIRC, you can turn it off with > -fno-merge-all-constants. > > -Eli >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120815/67d69c82/attachment.html>
On Wed, Aug 15, 2012 at 11:40 AM, Ryan Taylor <ryta1203 at gmail.com> wrote:> Eli, thanks for responding, unfortunately, this did not resolve my issue. > It's a locally allocated array in the C code, but I'm not seeing any alloca > in the IR just geps from the variable, which is never setup.That's strange; I just checked, and -fno-merge-all-constants definitely does have an effect for a simple testcase like the following (just using clang -emit-llvm at -O0): void f() { const int x[5] = {1,2,3,4}; } What does your testcase look like? -Eli
#define r10(p,q,r,s) 0x##s##r##q##p #undef r #define r r10 const word it_tab[4][256] = { r(const, const, const, const), r(.......), r(.......) ....... }; All of this is done inside the function I want the alloc in. The variable is not declared/defined/used anywhere else. On Wed, Aug 15, 2012 at 12:00 PM, Eli Friedman <eli.friedman at gmail.com>wrote:> On Wed, Aug 15, 2012 at 11:40 AM, Ryan Taylor <ryta1203 at gmail.com> wrote: > > Eli, thanks for responding, unfortunately, this did not resolve my issue. > > It's a locally allocated array in the C code, but I'm not seeing any > alloca > > in the IR just geps from the variable, which is never setup. > > That's strange; I just checked, and -fno-merge-all-constants > definitely does have an effect for a simple testcase like the > following (just using clang -emit-llvm at -O0): > > void f() { const int x[5] = {1,2,3,4}; } > > What does your testcase look like? > > -Eli >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120815/43b7fbcc/attachment.html>