Skip to content

Commit cd7f7cf

Browse files
committed
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 (62f09d7), 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.
1 parent 73bed64 commit cd7f7cf

File tree

12 files changed

+8
-66
lines changed

12 files changed

+8
-66
lines changed

llvm/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -706,18 +706,6 @@ endif()
706706

707707
option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF)
708708

709-
# While adding scalable vector support to LLVM, we temporarily want to
710-
# allow an implicit conversion of TypeSize to uint64_t, and to allow
711-
# code to get the fixed number of elements from a possibly scalable vector.
712-
# This CMake flag enables a more strict mode where it asserts that the type
713-
# is not a scalable vector type.
714-
#
715-
# Enabling this flag makes it easier to find cases where the compiler makes
716-
# assumptions on the size being 'fixed size', when building tests for
717-
# SVE/SVE2 or other scalable vector architectures.
718-
option(LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS
719-
"Enable assertions that type is not scalable in implicit conversion from TypeSize to uint64_t and calls to getNumElements" OFF)
720-
721709
set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
722710
"Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.")
723711

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,6 @@ if (LLVM_USES_LIBSTDCXX)
201201
endif()
202202
endif()
203203

204-
if (LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS)
205-
add_compile_definitions(STRICT_FIXED_SIZE_VECTORS)
206-
endif()
207-
208204
string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS)
209205

210206
if( uppercase_LLVM_ABI_BREAKING_CHECKS STREQUAL "WITH_ASSERTS" )

llvm/include/llvm/CodeGen/ValueTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ namespace llvm {
332332
assert(isVector() && "Invalid vector type!");
333333

334334
if (isScalableVector())
335-
llvm::reportInvalidSizeRequest(
335+
llvm::reportFatalInternalError(
336336
"Possible incorrect use of EVT::getVectorNumElements() for "
337337
"scalable vector. Scalable flag may be dropped, use "
338338
"EVT::getVectorElementCount() instead");

llvm/include/llvm/CodeGenTypes/LowLevelType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class LLT {
159159
/// vector types.
160160
constexpr uint16_t getNumElements() const {
161161
if (isScalable())
162-
llvm::reportInvalidSizeRequest(
162+
llvm::reportFatalInternalError(
163163
"Possible incorrect use of LLT::getNumElements() for "
164164
"scalable vector. Scalable flag may be dropped, use "
165165
"LLT::getElementCount() instead");

llvm/include/llvm/CodeGenTypes/MachineValueType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ namespace llvm {
294294

295295
unsigned getVectorNumElements() const {
296296
if (isScalableVector())
297-
llvm::reportInvalidSizeRequest(
297+
llvm::reportFatalInternalError(
298298
"Possible incorrect use of MVT::getVectorNumElements() for "
299299
"scalable vector. Scalable flag may be dropped, use "
300300
"MVT::getVectorElementCount() instead");

llvm/include/llvm/Support/TypeSize.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626

2727
namespace llvm {
2828

29-
/// Reports a diagnostic message to indicate an invalid size request has been
30-
/// done on a scalable vector. This function may not return.
31-
LLVM_ABI void reportInvalidSizeRequest(const char *Msg);
32-
3329
/// StackOffset holds a fixed and a scalable offset in bytes.
3430
class StackOffset {
3531
int64_t Fixed = 0;

llvm/lib/Support/CommandLine.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2671,7 +2671,6 @@ static void initCommonOptions() {
26712671
initSignalsOptions();
26722672
initStatisticOptions();
26732673
initTimerOptions();
2674-
initTypeSizeOptions();
26752674
initWithColorOptions();
26762675
initDebugOptions();
26772676
initRandomSeedOptions();

llvm/lib/Support/DebugOptions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ void initGraphWriterOptions();
2424
void initSignalsOptions();
2525
void initStatisticOptions();
2626
void initTimerOptions();
27-
void initTypeSizeOptions();
2827
void initWithColorOptions();
2928
void initDebugOptions();
3029
void initRandomSeedOptions();

llvm/lib/Support/TypeSize.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,13 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/Support/TypeSize.h"
10-
#include "llvm/Support/CommandLine.h"
11-
#include "llvm/Support/ManagedStatic.h"
12-
#include "llvm/Support/WithColor.h"
13-
14-
#include "DebugOptions.h"
10+
#include "llvm/Support/Error.h"
1511

1612
using namespace llvm;
1713

18-
#ifndef STRICT_FIXED_SIZE_VECTORS
19-
namespace {
20-
struct CreateScalableErrorAsWarning {
21-
/// The ScalableErrorAsWarning is a temporary measure to suppress errors from
22-
/// using the wrong interface on a scalable vector.
23-
static void *call() {
24-
return new cl::opt<bool>(
25-
"treat-scalable-fixed-error-as-warning", cl::Hidden,
26-
cl::desc(
27-
"Treat issues where a fixed-width property is requested from a "
28-
"scalable type as a warning, instead of an error"));
29-
}
30-
};
31-
} // namespace
32-
static ManagedStatic<cl::opt<bool>, CreateScalableErrorAsWarning>
33-
ScalableErrorAsWarning;
34-
void llvm::initTypeSizeOptions() { *ScalableErrorAsWarning; }
35-
#else
36-
void llvm::initTypeSizeOptions() {}
37-
#endif
38-
39-
void llvm::reportInvalidSizeRequest(const char *Msg) {
40-
#ifndef STRICT_FIXED_SIZE_VECTORS
41-
if (*ScalableErrorAsWarning) {
42-
WithColor::warning() << "Invalid size request on a scalable vector; " << Msg
43-
<< "\n";
44-
return;
45-
}
46-
#endif
47-
report_fatal_error("Invalid size request on a scalable vector.");
48-
}
49-
5014
TypeSize::operator TypeSize::ScalarTy() const {
5115
if (isScalable()) {
52-
reportInvalidSizeRequest(
16+
reportFatalInternalError(
5317
"Cannot implicitly convert a scalable size to a fixed-width size in "
5418
"`TypeSize::operator ScalarTy()`");
5519
return getKnownMinValue();

llvm/test/CodeGen/AArch64/sms-order-physreg-deps.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 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
1+
# 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
22

33
# REQUIRES: asserts
44

0 commit comments

Comments
 (0)