https://github.com/Ko496-glitch updated https://github.com/llvm/llvm-project/pull/189305
>From 2d47db0ff28f869363ed3808a82d6996dd07c2c5 Mon Sep 17 00:00:00 2001 From: kartikohlan <[email protected]> Date: Sun, 29 Mar 2026 23:49:47 -0400 Subject: [PATCH 1/5] [Clang] Fix assertion failure (#189260) --- clang/lib/CodeGen/CGExpr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 23802cdeb4811..737d4fd145a4d 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2781,6 +2781,10 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, Builder.getInt1Ty(), IRStoreTy->getPrimitiveSizeInBits()); Vec = Builder.CreateBitCast(Vec, IRVecTy); // iN --> <N x i1>. + + if(SrcVal->getType() != Builder.getInt1Ty()) + SrcVal = Builder.CreateTrunc(SrcVal,Builder.getInt1Ty()); + } } // Allow inserting `<1 x T>` into an `<N x T>`. It can happen with scalar >From 45a41f0bc15e448ab22921d14c7f39acae8d83b4 Mon Sep 17 00:00:00 2001 From: kartikohlan <[email protected]> Date: Mon, 30 Mar 2026 18:46:21 -0400 Subject: [PATCH 2/5] Added the exisiting practise and fixed the format --- clang/lib/CodeGen/CGExpr.cpp | 5 ++--- clang/test/CodeGen/ext-vector-bool-read.cpp | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 clang/test/CodeGen/ext-vector-bool-read.cpp diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 737d4fd145a4d..20a38b6367df5 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2782,9 +2782,8 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, Vec = Builder.CreateBitCast(Vec, IRVecTy); // iN --> <N x i1>. - if(SrcVal->getType() != Builder.getInt1Ty()) - SrcVal = Builder.CreateTrunc(SrcVal,Builder.getInt1Ty()); - } + SrcVal = Builder.CreateIntCast(SrcVal, Builder.getInt1Ty(), + /*isSigned=*/false); } // Allow inserting `<1 x T>` into an `<N x T>`. It can happen with scalar diff --git a/clang/test/CodeGen/ext-vector-bool-read.cpp b/clang/test/CodeGen/ext-vector-bool-read.cpp new file mode 100644 index 0000000000000..358dc5919b245 --- /dev/null +++ b/clang/test/CodeGen/ext-vector-bool-read.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O2 -o - %s | FileCheck %s + +// Regression test for GH#189260: Clang crashed with an assertion failure +// in InsertElementInst when storing to an element of an ext_vector_type +// with bool element type. + +typedef __attribute__((ext_vector_type(32))) bool v32bool; +v32bool v32b = {}; + +// CHECK-LABEL: @_Z5test1v +void test1() { + // CHECK: insertelement <32 x i1> + v32b[0] = true; +} + +// CHECK-LABEL: @_Z5test2v +void test2() { + // CHECK: insertelement <32 x i1> + v32b[31] = true; +} >From be6ade7e8e79586bcf3ad73fe9b981a679e972b0 Mon Sep 17 00:00:00 2001 From: kartikohlan <[email protected]> Date: Tue, 31 Mar 2026 08:32:31 -0400 Subject: [PATCH 3/5] Added release notes for #189260 --- clang/docs/ReleaseNotes.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index fc17eead02589..1ba369ff9f925 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -113,7 +113,7 @@ Clang Python Bindings Potentially Breaking Changes ``locations`` argument are passed. Previousy, ``locations`` took precedence. - ``_CXUnsavedFile`` will be renamed to ``UnsavedFile`` for consistency. ``UnsavedFile`` is already available to use and existing uses should - be adapted to refer to it instead. ``_CXUnsavedFile`` will be removed in a + be adapted to refer to it instead. ``_CXUnsavedFile`` will be removed in a future release. What's New in Clang |release|? @@ -324,7 +324,7 @@ Improvements to Clang's diagnostics when accessing a member function on a past-the-end array element. (#GH179128) -- Added a missing space to the FixIt for the ``implicit-int`` group of diagnostics and +- Added a missing space to the FixIt for the ``implicit-int`` group of diagnostics and made sure that only one such diagnostic and FixIt is emitted per declaration group. (#GH179354) - Fixed the Fix-It insertion point for ``expected ';' after alias declaration`` @@ -337,7 +337,7 @@ Improvements to Clang's diagnostics - The ``-Wloop-analysis`` warning has been extended to catch more cases of variable modification inside lambda expressions (#GH132038). -- Clang now emits ``-Wsizeof-pointer-memaccess`` when snprintf/vsnprintf use the sizeof +- Clang now emits ``-Wsizeof-pointer-memaccess`` when snprintf/vsnprintf use the sizeof the destination buffer(dynamically allocated) in the len parameter(#GH162366) - Added ``-Wmodule-map-path-outside-directory`` (off by default) to warn on @@ -384,6 +384,7 @@ Bug Fixes in This Version - Correctly diagnosing and no longer crashing when ``export module foo`` (without a semicolon) are the final tokens in a module file. (#GH187771) - Fixed a crash in duplicate attribute checking caused by comparing constant arguments with different integer signedness. (#GH188259) +- Fixed a crash when assigning to an element of an ``ext_vector_type`` with ``bool`` element type. (#GH189260) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -406,7 +407,7 @@ Bug Fixes to C++ Support - Fixed a crash when diagnosing an invalid static member function with an explicit object parameter (#GH177741) - Fixed a crash when instantiating an invalid out-of-line static data member definition in a local class. (#GH176152) - Fixed a crash when pack expansions are used as arguments for non-pack parameters of built-in templates. (#GH180307) -- Fixed a bug where captured variables in non-mutable lambdas were incorrectly treated as mutable +- Fixed a bug where captured variables in non-mutable lambdas were incorrectly treated as mutable when used inside decltype in the return type. (#GH180460) - Fixed a crash when evaluating uninitialized GCC vector/ext_vector_type vectors in ``constexpr``. (#GH180044) - Fixed a crash when `explicit(bool)` is used with an incomplete enumeration. (#GH183887) @@ -414,8 +415,8 @@ Bug Fixes to C++ Support - Fixed a crash when an immediate-invoked ``consteval`` lambda is used as an invalid initializer. (#GH185270) - Fixed an assertion failure when using a global destructor with a target with a non-default program address space. (#GH186484) -- Inherited constructors in ``dllexport`` classes are now exported for ABI-compatible cases, matching - MSVC behavior. Constructors with variadic arguments or callee-cleanup parameters are not yet supported +- Inherited constructors in ``dllexport`` classes are now exported for ABI-compatible cases, matching + MSVC behavior. Constructors with variadic arguments or callee-cleanup parameters are not yet supported and produce a warning. (#GH162640) - Fix initialization of GRO when GRO-return type mismatches, as part of CWG2563. (#GH98744) >From 7c0ffc888eb6320b9799277e1fddc216ca8b5f06 Mon Sep 17 00:00:00 2001 From: kartikohlan <[email protected]> Date: Fri, 3 Apr 2026 12:59:39 -0400 Subject: [PATCH 4/5] Added the update_cc_test_checks.py checks and added VecTy->isVectorTy() --- clang/lib/CodeGen/CGExpr.cpp | 7 +-- clang/test/CodeGen/ext-vector-bool-read.cpp | 47 ++++++++++++++++++--- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 20a38b6367df5..2ef399a7e7309 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2771,8 +2771,8 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, llvm::Type *VecTy = Vec->getType(); llvm::Value *SrcVal = Src.getScalarVal(); - if (SrcVal->getType()->getPrimitiveSizeInBits() < - VecTy->getScalarSizeInBits()) + if (VecTy->isVectorTy() && SrcVal->getType()->getPrimitiveSizeInBits() < + VecTy->getScalarSizeInBits()) SrcVal = Builder.CreateZExt(SrcVal, VecTy->getScalarType()); auto *IRStoreTy = dyn_cast<llvm::IntegerType>(Vec->getType()); @@ -2781,9 +2781,6 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, Builder.getInt1Ty(), IRStoreTy->getPrimitiveSizeInBits()); Vec = Builder.CreateBitCast(Vec, IRVecTy); // iN --> <N x i1>. - - SrcVal = Builder.CreateIntCast(SrcVal, Builder.getInt1Ty(), - /*isSigned=*/false); } // Allow inserting `<1 x T>` into an `<N x T>`. It can happen with scalar diff --git a/clang/test/CodeGen/ext-vector-bool-read.cpp b/clang/test/CodeGen/ext-vector-bool-read.cpp index 358dc5919b245..527cf160c1614 100644 --- a/clang/test/CodeGen/ext-vector-bool-read.cpp +++ b/clang/test/CodeGen/ext-vector-bool-read.cpp @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O2 -o - %s | FileCheck %s +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O2 -o - %s | FileCheck %s --check-prefix=OPT // Regression test for GH#189260: Clang crashed with an assertion failure // in InsertElementInst when storing to an element of an ext_vector_type @@ -8,14 +9,48 @@ typedef __attribute__((ext_vector_type(32))) bool v32bool; v32bool v32b = {}; -// CHECK-LABEL: @_Z5test1v +// CHECK-LABEL: define dso_local void @_Z5test1v( +// CHECK-SAME: ) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @v32b, align 4 +// CHECK-NEXT: [[TMP1:%.*]] = bitcast i32 [[TMP0]] to <32 x i1> +// CHECK-NEXT: [[VECINS:%.*]] = insertelement <32 x i1> [[TMP1]], i1 true, i32 0 +// CHECK-NEXT: [[TMP2:%.*]] = bitcast <32 x i1> [[VECINS]] to i32 +// CHECK-NEXT: store i32 [[TMP2]], ptr @v32b, align 4 +// CHECK-NEXT: ret void +// +// OPT-LABEL: define dso_local void @_Z5test1v( +// OPT-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// OPT-NEXT: [[ENTRY:.*:]] +// OPT-NEXT: [[TMP0:%.*]] = load <32 x i1>, ptr @v32b, align 4 +// OPT-NEXT: [[VECINS:%.*]] = insertelement <32 x i1> [[TMP0]], i1 true, i64 0 +// OPT-NEXT: store <32 x i1> [[VECINS]], ptr @v32b, align 4 +// OPT-NEXT: ret void +// void test1() { - // CHECK: insertelement <32 x i1> + v32b[0] = true; } -// CHECK-LABEL: @_Z5test2v +// CHECK-LABEL: define dso_local void @_Z5test2v( +// CHECK-SAME: ) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @v32b, align 4 +// CHECK-NEXT: [[TMP1:%.*]] = bitcast i32 [[TMP0]] to <32 x i1> +// CHECK-NEXT: [[VECINS:%.*]] = insertelement <32 x i1> [[TMP1]], i1 true, i32 31 +// CHECK-NEXT: [[TMP2:%.*]] = bitcast <32 x i1> [[VECINS]] to i32 +// CHECK-NEXT: store i32 [[TMP2]], ptr @v32b, align 4 +// CHECK-NEXT: ret void +// +// OPT-LABEL: define dso_local void @_Z5test2v( +// OPT-SAME: ) local_unnamed_addr #[[ATTR0]] { +// OPT-NEXT: [[ENTRY:.*:]] +// OPT-NEXT: [[TMP0:%.*]] = load <32 x i1>, ptr @v32b, align 4 +// OPT-NEXT: [[VECINS:%.*]] = insertelement <32 x i1> [[TMP0]], i1 true, i64 31 +// OPT-NEXT: store <32 x i1> [[VECINS]], ptr @v32b, align 4 +// OPT-NEXT: ret void +// void test2() { - // CHECK: insertelement <32 x i1> + v32b[31] = true; } >From c3ef77319a6e01781a7350b9631050c97111028f Mon Sep 17 00:00:00 2001 From: kartikohlan <[email protected]> Date: Mon, 6 Apr 2026 01:16:28 -0400 Subject: [PATCH 5/5] reset to original version --- clang/docs/ReleaseNotes.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 1ba369ff9f925..fc17eead02589 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -113,7 +113,7 @@ Clang Python Bindings Potentially Breaking Changes ``locations`` argument are passed. Previousy, ``locations`` took precedence. - ``_CXUnsavedFile`` will be renamed to ``UnsavedFile`` for consistency. ``UnsavedFile`` is already available to use and existing uses should - be adapted to refer to it instead. ``_CXUnsavedFile`` will be removed in a + be adapted to refer to it instead. ``_CXUnsavedFile`` will be removed in a future release. What's New in Clang |release|? @@ -324,7 +324,7 @@ Improvements to Clang's diagnostics when accessing a member function on a past-the-end array element. (#GH179128) -- Added a missing space to the FixIt for the ``implicit-int`` group of diagnostics and +- Added a missing space to the FixIt for the ``implicit-int`` group of diagnostics and made sure that only one such diagnostic and FixIt is emitted per declaration group. (#GH179354) - Fixed the Fix-It insertion point for ``expected ';' after alias declaration`` @@ -337,7 +337,7 @@ Improvements to Clang's diagnostics - The ``-Wloop-analysis`` warning has been extended to catch more cases of variable modification inside lambda expressions (#GH132038). -- Clang now emits ``-Wsizeof-pointer-memaccess`` when snprintf/vsnprintf use the sizeof +- Clang now emits ``-Wsizeof-pointer-memaccess`` when snprintf/vsnprintf use the sizeof the destination buffer(dynamically allocated) in the len parameter(#GH162366) - Added ``-Wmodule-map-path-outside-directory`` (off by default) to warn on @@ -384,7 +384,6 @@ Bug Fixes in This Version - Correctly diagnosing and no longer crashing when ``export module foo`` (without a semicolon) are the final tokens in a module file. (#GH187771) - Fixed a crash in duplicate attribute checking caused by comparing constant arguments with different integer signedness. (#GH188259) -- Fixed a crash when assigning to an element of an ``ext_vector_type`` with ``bool`` element type. (#GH189260) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -407,7 +406,7 @@ Bug Fixes to C++ Support - Fixed a crash when diagnosing an invalid static member function with an explicit object parameter (#GH177741) - Fixed a crash when instantiating an invalid out-of-line static data member definition in a local class. (#GH176152) - Fixed a crash when pack expansions are used as arguments for non-pack parameters of built-in templates. (#GH180307) -- Fixed a bug where captured variables in non-mutable lambdas were incorrectly treated as mutable +- Fixed a bug where captured variables in non-mutable lambdas were incorrectly treated as mutable when used inside decltype in the return type. (#GH180460) - Fixed a crash when evaluating uninitialized GCC vector/ext_vector_type vectors in ``constexpr``. (#GH180044) - Fixed a crash when `explicit(bool)` is used with an incomplete enumeration. (#GH183887) @@ -415,8 +414,8 @@ Bug Fixes to C++ Support - Fixed a crash when an immediate-invoked ``consteval`` lambda is used as an invalid initializer. (#GH185270) - Fixed an assertion failure when using a global destructor with a target with a non-default program address space. (#GH186484) -- Inherited constructors in ``dllexport`` classes are now exported for ABI-compatible cases, matching - MSVC behavior. Constructors with variadic arguments or callee-cleanup parameters are not yet supported +- Inherited constructors in ``dllexport`` classes are now exported for ABI-compatible cases, matching + MSVC behavior. Constructors with variadic arguments or callee-cleanup parameters are not yet supported and produce a warning. (#GH162640) - Fix initialization of GRO when GRO-return type mismatches, as part of CWG2563. (#GH98744) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
