llvm compile too much memory when i userd global array

hi,all
when my code like

Does it really make a difference what size the array is?

Debug or release build of clang?

I recently started looking into a similar issue. What I have found is that during
compilation, clang will store a representation of the initialized array in memory.
This internal representation is used during codegen to emit the initialized
contents as IR. I assume this is similar for your case, the static array being
initialized as 0. The, I assume similar case, that I am investigating is the following:

// test.c: clang -c test.c
int data[1024 * 1024 * 1024] = {1,2,3};
// end of test

To represent the above code in IR, clang will generate an internal SmallVector
that contains 1024*1024*1024 elements. The first three will be initialized
to 1,2,3 respectively, and the remaining will be 0 elements. From my
experience looking into the aforementioned case, large initialized arrays ca
produce the behavior that you are seeing. The main difference between our
cases is that you are representing an initialized array of non-POD items.

-Matt