Files
clang-p2996/clang/test/CodeGen/ext-int.c
Craig Topper 2fd180bbb9 [IR] Reduce max supported integer from 2^24-1 to 2^23.
SelectionDAG will promote illegal types up to a power of 2 before
splitting down to a legal type. This will create an IntegerType
with a bit width that must be <= MAX_INT_BITS. This places an
effective upper limit on any type of 2^23 so that we don't try
create a 2^24 type.

I considered putting a fatal error somewhere in the path from
TargetLowering::getTypeConversion down to IntegerType::get, but
limiting the type in IR seemed better.

This breaks backwards compatibility with IR that is using a really
large type. I suspect such IR is going to be very rare due to the
the compile time costs such a type likely incurs.

Prevents the ICE in PR51829.

Reviewed By: efriedma, aaron.ballman

Differential Revision: https://reviews.llvm.org/D109721
2021-09-14 07:52:10 -07:00

61 lines
2.5 KiB
C

// RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK64
// RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK64
// RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN32
// RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN32
void GenericTest(_ExtInt(3) a, unsigned _ExtInt(3) b, _ExtInt(4) c) {
// CHECK: define {{.*}}void @GenericTest
int which = _Generic(a, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3);
// CHECK: store i32 1
int which2 = _Generic(b, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3);
// CHECK: store i32 2
int which3 = _Generic(c, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3);
// CHECK: store i32 3
}
void VLATest(_ExtInt(3) A, _ExtInt(99) B, _ExtInt(123456) C) {
// CHECK: define {{.*}}void @VLATest
int AR1[A];
// CHECK: %[[A:.+]] = zext i3 %{{.+}} to i[[INDXSIZE:[0-9]+]]
// CHECK: %[[VLA1:.+]] = alloca i32, i[[INDXSIZE]] %[[A]]
int AR2[B];
// CHECK: %[[B:.+]] = trunc i99 %{{.+}} to i[[INDXSIZE]]
// CHECK: %[[VLA2:.+]] = alloca i32, i[[INDXSIZE]] %[[B]]
int AR3[C];
// CHECK: %[[C:.+]] = trunc i123456 %{{.+}} to i[[INDXSIZE]]
// CHECK: %[[VLA3:.+]] = alloca i32, i[[INDXSIZE]] %[[C]]
}
struct S {
_ExtInt(17) A;
_ExtInt(8388600) B;
_ExtInt(17) C;
};
void OffsetOfTest() {
// CHECK: define {{.*}}void @OffsetOfTest
int A = __builtin_offsetof(struct S,A);
// CHECK: store i32 0, i32* %{{.+}}
int B = __builtin_offsetof(struct S,B);
// CHECK64: store i32 8, i32* %{{.+}}
// LIN32: store i32 4, i32* %{{.+}}
// WINCHECK32: store i32 8, i32* %{{.+}}
int C = __builtin_offsetof(struct S,C);
// CHECK64: store i32 1048584, i32* %{{.+}}
// LIN32: store i32 1048580, i32* %{{.+}}
// WIN32: store i32 1048584, i32* %{{.+}}
}
void Size1ExtIntParam(unsigned _ExtInt(1) A) {
// CHECK: define {{.*}}void @Size1ExtIntParam(i1{{.*}} %[[PARAM:.+]])
// CHECK: %[[PARAM_ADDR:.+]] = alloca i1
// CHECK: %[[B:.+]] = alloca [5 x i1]
// CHECK: store i1 %[[PARAM]], i1* %[[PARAM_ADDR]]
unsigned _ExtInt(1) B[5];
// CHECK: %[[PARAM_LOAD:.+]] = load i1, i1* %[[PARAM_ADDR]]
// CHECK: %[[IDX:.+]] = getelementptr inbounds [5 x i1], [5 x i1]* %[[B]]
// CHECK: store i1 %[[PARAM_LOAD]], i1* %[[IDX]]
B[2] = A;
}