aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-09-02 09:10:45 +0200
committerNikita Popov <npopov@redhat.com>2025-09-03 11:12:11 +0200
commitcd7f7cf5cca6fa425523a5af9fd42f82c6566ebf (patch)
treec8a427383e767538b1ea388984c00f451c48bd8f
parent73bed64433072338d11ebf770d6db99c2ce810aa (diff)
downloadllvm-cd7f7cf5cca6fa425523a5af9fd42f82c6566ebf.zip
llvm-cd7f7cf5cca6fa425523a5af9fd42f82c6566ebf.tar.gz
llvm-cd7f7cf5cca6fa425523a5af9fd42f82c6566ebf.tar.bz2
Reapply [IR] Remove options to make scalable TypeSize access a warning (#156336)
Reapplying now that buildbot has picked up the new configuration that does not use -treat-scalable-fixed-error-as-warning. ----- This removes the `LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS` cmake option and the `-treat-scalable-fixed-error-as-warning` opt flag. We stopped treating these as warnings by default a long time ago (62f09d788f9fc540db12f3cfa2f98760071fca96), so I don't think it makes sense to retain these options at this point. Accessing a scalable TypeSize as fixed should always result in an error.
-rw-r--r--llvm/CMakeLists.txt12
-rw-r--r--llvm/cmake/modules/HandleLLVMOptions.cmake4
-rw-r--r--llvm/include/llvm/CodeGen/ValueTypes.h2
-rw-r--r--llvm/include/llvm/CodeGenTypes/LowLevelType.h2
-rw-r--r--llvm/include/llvm/CodeGenTypes/MachineValueType.h2
-rw-r--r--llvm/include/llvm/Support/TypeSize.h4
-rw-r--r--llvm/lib/Support/CommandLine.cpp1
-rw-r--r--llvm/lib/Support/DebugOptions.h1
-rw-r--r--llvm/lib/Support/TypeSize.cpp40
-rw-r--r--llvm/test/CodeGen/AArch64/sms-order-physreg-deps.mir2
-rw-r--r--llvm/test/CodeGen/AArch64/sve-unaligned-load-store-strict-align.ll2
-rw-r--r--llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.ptr.buffer.store.nxv2i32.fail.ll2
12 files changed, 8 insertions, 66 deletions
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index a90be4f..3eb6956 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -706,18 +706,6 @@ endif()
option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF)
-# While adding scalable vector support to LLVM, we temporarily want to
-# allow an implicit conversion of TypeSize to uint64_t, and to allow
-# code to get the fixed number of elements from a possibly scalable vector.
-# This CMake flag enables a more strict mode where it asserts that the type
-# is not a scalable vector type.
-#
-# Enabling this flag makes it easier to find cases where the compiler makes
-# assumptions on the size being 'fixed size', when building tests for
-# SVE/SVE2 or other scalable vector architectures.
-option(LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS
- "Enable assertions that type is not scalable in implicit conversion from TypeSize to uint64_t and calls to getNumElements" OFF)
-
set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
"Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.")
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 97aa131..a67543c 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -201,10 +201,6 @@ if (LLVM_USES_LIBSTDCXX)
endif()
endif()
-if (LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS)
- add_compile_definitions(STRICT_FIXED_SIZE_VECTORS)
-endif()
-
string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS)
if( uppercase_LLVM_ABI_BREAKING_CHECKS STREQUAL "WITH_ASSERTS" )
diff --git a/llvm/include/llvm/CodeGen/ValueTypes.h b/llvm/include/llvm/CodeGen/ValueTypes.h
index 2a91cdc..43aaa2b 100644
--- a/llvm/include/llvm/CodeGen/ValueTypes.h
+++ b/llvm/include/llvm/CodeGen/ValueTypes.h
@@ -332,7 +332,7 @@ namespace llvm {
assert(isVector() && "Invalid vector type!");
if (isScalableVector())
- llvm::reportInvalidSizeRequest(
+ llvm::reportFatalInternalError(
"Possible incorrect use of EVT::getVectorNumElements() for "
"scalable vector. Scalable flag may be dropped, use "
"EVT::getVectorElementCount() instead");
diff --git a/llvm/include/llvm/CodeGenTypes/LowLevelType.h b/llvm/include/llvm/CodeGenTypes/LowLevelType.h
index d8e0848..4c1fe13 100644
--- a/llvm/include/llvm/CodeGenTypes/LowLevelType.h
+++ b/llvm/include/llvm/CodeGenTypes/LowLevelType.h
@@ -159,7 +159,7 @@ public:
/// vector types.
constexpr uint16_t getNumElements() const {
if (isScalable())
- llvm::reportInvalidSizeRequest(
+ llvm::reportFatalInternalError(
"Possible incorrect use of LLT::getNumElements() for "
"scalable vector. Scalable flag may be dropped, use "
"LLT::getElementCount() instead");
diff --git a/llvm/include/llvm/CodeGenTypes/MachineValueType.h b/llvm/include/llvm/CodeGenTypes/MachineValueType.h
index b8e91a0..389bae2 100644
--- a/llvm/include/llvm/CodeGenTypes/MachineValueType.h
+++ b/llvm/include/llvm/CodeGenTypes/MachineValueType.h
@@ -294,7 +294,7 @@ namespace llvm {
unsigned getVectorNumElements() const {
if (isScalableVector())
- llvm::reportInvalidSizeRequest(
+ llvm::reportFatalInternalError(
"Possible incorrect use of MVT::getVectorNumElements() for "
"scalable vector. Scalable flag may be dropped, use "
"MVT::getVectorElementCount() instead");
diff --git a/llvm/include/llvm/Support/TypeSize.h b/llvm/include/llvm/Support/TypeSize.h
index 9642529..b6926e6 100644
--- a/llvm/include/llvm/Support/TypeSize.h
+++ b/llvm/include/llvm/Support/TypeSize.h
@@ -26,10 +26,6 @@
namespace llvm {
-/// Reports a diagnostic message to indicate an invalid size request has been
-/// done on a scalable vector. This function may not return.
-LLVM_ABI void reportInvalidSizeRequest(const char *Msg);
-
/// StackOffset holds a fixed and a scalable offset in bytes.
class StackOffset {
int64_t Fixed = 0;
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 8491633..be232f5 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -2671,7 +2671,6 @@ static void initCommonOptions() {
initSignalsOptions();
initStatisticOptions();
initTimerOptions();
- initTypeSizeOptions();
initWithColorOptions();
initDebugOptions();
initRandomSeedOptions();
diff --git a/llvm/lib/Support/DebugOptions.h b/llvm/lib/Support/DebugOptions.h
index db727d5..6c3382e 100644
--- a/llvm/lib/Support/DebugOptions.h
+++ b/llvm/lib/Support/DebugOptions.h
@@ -24,7 +24,6 @@ void initGraphWriterOptions();
void initSignalsOptions();
void initStatisticOptions();
void initTimerOptions();
-void initTypeSizeOptions();
void initWithColorOptions();
void initDebugOptions();
void initRandomSeedOptions();
diff --git a/llvm/lib/Support/TypeSize.cpp b/llvm/lib/Support/TypeSize.cpp
index 43346b8..3dbb008 100644
--- a/llvm/lib/Support/TypeSize.cpp
+++ b/llvm/lib/Support/TypeSize.cpp
@@ -7,49 +7,13 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/TypeSize.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/WithColor.h"
-
-#include "DebugOptions.h"
+#include "llvm/Support/Error.h"
using namespace llvm;
-#ifndef STRICT_FIXED_SIZE_VECTORS
-namespace {
-struct CreateScalableErrorAsWarning {
- /// The ScalableErrorAsWarning is a temporary measure to suppress errors from
- /// using the wrong interface on a scalable vector.
- static void *call() {
- return new cl::opt<bool>(
- "treat-scalable-fixed-error-as-warning", cl::Hidden,
- cl::desc(
- "Treat issues where a fixed-width property is requested from a "
- "scalable type as a warning, instead of an error"));
- }
-};
-} // namespace
-static ManagedStatic<cl::opt<bool>, CreateScalableErrorAsWarning>
- ScalableErrorAsWarning;
-void llvm::initTypeSizeOptions() { *ScalableErrorAsWarning; }
-#else
-void llvm::initTypeSizeOptions() {}
-#endif
-
-void llvm::reportInvalidSizeRequest(const char *Msg) {
-#ifndef STRICT_FIXED_SIZE_VECTORS
- if (*ScalableErrorAsWarning) {
- WithColor::warning() << "Invalid size request on a scalable vector; " << Msg
- << "\n";
- return;
- }
-#endif
- report_fatal_error("Invalid size request on a scalable vector.");
-}
-
TypeSize::operator TypeSize::ScalarTy() const {
if (isScalable()) {
- reportInvalidSizeRequest(
+ reportFatalInternalError(
"Cannot implicitly convert a scalable size to a fixed-width size in "
"`TypeSize::operator ScalarTy()`");
return getKnownMinValue();
diff --git a/llvm/test/CodeGen/AArch64/sms-order-physreg-deps.mir b/llvm/test/CodeGen/AArch64/sms-order-physreg-deps.mir
index 4d8067e..61e3c73 100644
--- a/llvm/test/CodeGen/AArch64/sms-order-physreg-deps.mir
+++ b/llvm/test/CodeGen/AArch64/sms-order-physreg-deps.mir
@@ -1,4 +1,4 @@
-# RUN: llc --verify-machineinstrs -mtriple=aarch64 -o - %s -mcpu=a64fx -aarch64-enable-pipeliner -pipeliner-max-mii=100 -pipeliner-enable-copytophi=0 -debug-only=pipeliner -run-pass=pipeliner -treat-scalable-fixed-error-as-warning 2>&1 | FileCheck %s
+# RUN: llc --verify-machineinstrs -mtriple=aarch64 -o - %s -mcpu=a64fx -aarch64-enable-pipeliner -pipeliner-max-mii=100 -pipeliner-enable-copytophi=0 -debug-only=pipeliner -run-pass=pipeliner 2>&1 | FileCheck %s
# REQUIRES: asserts
diff --git a/llvm/test/CodeGen/AArch64/sve-unaligned-load-store-strict-align.ll b/llvm/test/CodeGen/AArch64/sve-unaligned-load-store-strict-align.ll
index 981ccdb..78325a1 100644
--- a/llvm/test/CodeGen/AArch64/sve-unaligned-load-store-strict-align.ll
+++ b/llvm/test/CodeGen/AArch64/sve-unaligned-load-store-strict-align.ll
@@ -5,7 +5,7 @@
; REQUIRES: asserts
; FIXME: Support TLI.expandUnalignedLoad()/TLI.expandUnalignedStore() for SVE.
-; CHECK-FIXME: LLVM ERROR: Invalid size request on a scalable vector.
+; CHECK-FIXME: LLVM ERROR: Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()
define void @unaligned_nxv16i1(ptr %ldptr, ptr %stptr) {
; CHECK-LABEL: unaligned_nxv16i1:
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.ptr.buffer.store.nxv2i32.fail.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.ptr.buffer.store.nxv2i32.fail.ll
index a91d38a5..23ea84c 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.ptr.buffer.store.nxv2i32.fail.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.ptr.buffer.store.nxv2i32.fail.ll
@@ -3,7 +3,7 @@
; RUN: not --crash llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx900 -filetype=null < %s 2>&1 | FileCheck %s --check-prefix=SDAG
; SDAG: LLVM ERROR: Scalarization of scalable vectors is not supported.
; RUN: not --crash llc -global-isel=1 -mtriple=amdgcn -mcpu=gfx900 -filetype=null < %s 2>&1 | FileCheck %s --check-prefix=GISEL
-; GISEL: LLVM ERROR: Invalid size request on a scalable vector.
+; GISEL: LLVM ERROR: Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
define void @buffer_store_nxv2i32(ptr addrspace(8) inreg %rsrc, i32 %offset) {
call void @llvm.amdgcn.raw.ptr.buffer.store.nxv2i32(<vscale x 2 x i32> poison, ptr addrspace(8) %rsrc, i32 %offset, i32 0, i32 0)