diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-29 00:28:29 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-29 00:28:29 +0800 |
| commit | 14a02f58dffc0e34f2cea914f207d9d37773b759 (patch) | |
| tree | 6d04530827c852aa0257f6b80cf70721318f217a /backend | |
| parent | 294cefacabb7dbf954cbb70dbb724745eeba3abc (diff) | |
| download | rcc-project-14a02f58dffc0e34f2cea914f207d9d37773b759.tar.gz rcc-project-14a02f58dffc0e34f2cea914f207d9d37773b759.tar.xz | |
[GlobalISel] Assert vector element type invariants
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/lib/CodeGen/GlobalISel/Utils.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/backend/lib/CodeGen/GlobalISel/Utils.cpp b/backend/lib/CodeGen/GlobalISel/Utils.cpp index 0f8d638..f9d6b0a 100644 --- a/backend/lib/CodeGen/GlobalISel/Utils.cpp +++ b/backend/lib/CodeGen/GlobalISel/Utils.cpp @@ -11,6 +11,7 @@ #include "rcc/CodeGen/MachineRegisterInfo.h" #include "rcc/CodeGen/TargetDescription.h" +#include <cassert> #include <cstdint> #include <numeric> #include <optional> @@ -89,7 +90,9 @@ namespace { "vector part extraction requires a fixed vector and a nonzero element count"); } - const LowLevelType ElementType = *RegisterType->scalarElementType(); + const std::optional<LowLevelType> ElementTypeValue = RegisterType->scalarElementType(); + assert(ElementTypeValue && "validated vector type must have an element type"); + const LowLevelType ElementType = *ElementTypeValue; auto NarrowType = makeVectorType(ElementCount, false, ElementType); if (!NarrowType) return std::unexpected(NarrowType.error()); @@ -325,8 +328,9 @@ Expected<bool> extractParts(Register Reg, LowLevelType RegisterType, LowLevelTyp if (LeftoverElementCount > 1 && MainElementCount % LeftoverElementCount == 0 && RegisterElementCount % LeftoverElementCount == 0 && RegisterType.scalarBitWidth() == MainType.scalarBitWidth()) { - auto Candidate = - LowLevelType::makeFixedVector(LeftoverElementCount, *RegisterType.scalarElementType()); + const std::optional<LowLevelType> ElementType = RegisterType.scalarElementType(); + assert(ElementType && "validated vector type must have an element type"); + auto Candidate = LowLevelType::makeFixedVector(LeftoverElementCount, *ElementType); if (!Candidate) return std::unexpected(Candidate.error()); LeftoverType = *Candidate; |
