Author: Erich Keane Date: 2020-08-05T10:54:51-07:00 New Revision: 2143a90b34a7846369127e762cec5917d5e1a5bd
URL: https://github.com/llvm/llvm-project/commit/2143a90b34a7846369127e762cec5917d5e1a5bd DIFF: https://github.com/llvm/llvm-project/commit/2143a90b34a7846369127e762cec5917d5e1a5bd.diff LOG: Fix _ExtInt(1) to be a i1 in memory. The _ExtInt(1) in getTypeForMem was hitting the bool logic for expanding to an 8 bit value. The result was an assert, or store i1 %0, i8* %2, align 1 since the parameter IS an i1. This patch changes the 'forMem' test to exclude ext-int from the bool test. Added: Modified: clang/lib/CodeGen/CodeGenTypes.cpp clang/test/CodeGen/ext-int.c Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index d431c0263666..cad63fee4570 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -93,7 +93,8 @@ llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T, bool ForBitField) { // If this is a bool type, or an ExtIntType in a bitfield representation, // map this integer to the target-specified size. - if ((ForBitField && T->isExtIntType()) || R->isIntegerTy(1)) + if ((ForBitField && T->isExtIntType()) || + (!T->isExtIntType() && R->isIntegerTy(1))) return llvm::IntegerType::get(getLLVMContext(), (unsigned)Context.getTypeSize(T)); diff --git a/clang/test/CodeGen/ext-int.c b/clang/test/CodeGen/ext-int.c index 196bb810b61a..d8e763283bfd 100644 --- a/clang/test/CodeGen/ext-int.c +++ b/clang/test/CodeGen/ext-int.c @@ -45,3 +45,16 @@ void OffsetOfTest() { // LIN32: store i32 2097156, i32* %{{.+}} // WIN32: store i32 2097160, 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; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits