|
7 | 7 | //===----------------------------------------------------------------------===//
|
8 | 8 |
|
9 | 9 | #include "llvm/Support/TypeSize.h"
|
10 |
| -#include "llvm/Support/Error.h" |
| 10 | +#include "llvm/Support/CommandLine.h" |
| 11 | +#include "llvm/Support/ManagedStatic.h" |
| 12 | +#include "llvm/Support/WithColor.h" |
| 13 | + |
| 14 | +#include "DebugOptions.h" |
11 | 15 |
|
12 | 16 | using namespace llvm;
|
13 | 17 |
|
| 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 | + |
14 | 50 | TypeSize::operator TypeSize::ScalarTy() const {
|
15 | 51 | if (isScalable()) {
|
16 |
| - reportFatalInternalError( |
| 52 | + reportInvalidSizeRequest( |
17 | 53 | "Cannot implicitly convert a scalable size to a fixed-width size in "
|
18 | 54 | "`TypeSize::operator ScalarTy()`");
|
19 | 55 | return getKnownMinValue();
|
|
0 commit comments