xref: /aosp_15_r20/external/llvm/test/Transforms/Inline/array-alloca.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -inline -S < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker%struct.A = type { i32 }
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workerdefine void @callee1(i32 %M) {
5*9880d681SAndroid Build Coastguard Workerentry:
6*9880d681SAndroid Build Coastguard Worker  %vla = alloca i32, i32 %M, align 16
7*9880d681SAndroid Build Coastguard Worker  ret void
8*9880d681SAndroid Build Coastguard Worker}
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine void @callee2(i32 %M) {
11*9880d681SAndroid Build Coastguard Workerentry:
12*9880d681SAndroid Build Coastguard Worker  %vla = alloca %struct.A, i32 %M, align 16
13*9880d681SAndroid Build Coastguard Worker  ret void
14*9880d681SAndroid Build Coastguard Worker}
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerdefine void @callee3(i128 %M) {
17*9880d681SAndroid Build Coastguard Workerentry:
18*9880d681SAndroid Build Coastguard Worker  %vla = alloca i32, i128 %M, align 16
19*9880d681SAndroid Build Coastguard Worker  ret void
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @caller
23*9880d681SAndroid Build Coastguard Workerdefine void @caller() #0 {
24*9880d681SAndroid Build Coastguard Workerentry:
25*9880d681SAndroid Build Coastguard Worker  call void @caller()
26*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: call void @callee1
27*9880d681SAndroid Build Coastguard Worker  call void @callee1(i32 256)
28*9880d681SAndroid Build Coastguard Worker; CHECK: call void @callee2
29*9880d681SAndroid Build Coastguard Worker  call void @callee2(i32 4096)
30*9880d681SAndroid Build Coastguard Worker; CHECK: call void @callee3
31*9880d681SAndroid Build Coastguard Worker; This is to test that there is no overflow in computing allocated size
32*9880d681SAndroid Build Coastguard Worker; call void @callee3(i128 0x8000000000000000);
33*9880d681SAndroid Build Coastguard Worker  call void @callee3(i128 9223372036854775808);
34*9880d681SAndroid Build Coastguard Worker  ret void
35*9880d681SAndroid Build Coastguard Worker}
36*9880d681SAndroid Build Coastguard Worker
37