LLVM check if array allocation has dynamic size or constant size
<p>I want to check if an stack allocation of an array has a constant size or a dynamic size (calculated at runtime). For example</p>

<pre><code>int myInt;
scanf("%d", &amp;myInt);
int buffer[myInt]; //dynamic sized array
</code></pre>

<p>The dynamic sized array gets converted to llvm IR like this:</p>

<pre><code>%myInt = alloca i32, align 4
%saved_stack = alloca i8*
%call = call i32 (i8*, ...) @__isoc99_scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i32* %myInt)
%0 = load i32, i32* %myInt, align 4
%1 = zext i32 %0 to i64
%2 = call i8* @llvm.stacksave()
store i8* %2, i8** %saved_stack
%vla = alloca i32, i64 %1, align 16 //allocation
%3 = load i8*, i8** %saved_stack
call void @llvm.stackrestore(i8* %3)
</code></pre>

<p>A constant sized array:</p>

<pre><code>int buffer2[123]; 
</code></pre>

<p>LLVM IR:</p>

<pre><code>%buffer2 = alloca [123 x i32], align 16 
</code></pre>

<p>How can I identify if an alloca instruction allocates a dynamically sized array or a constant sized array?</p>