[PATCH] D86240: [llvm] Do not delete default constructor of `llvm::ElementCount`.

Francesco Petrogalli via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 13:00:11 PDT 2020


fpetrogalli created this revision.
fpetrogalli added a reviewer: ormris.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
fpetrogalli requested review of this revision.

This patch prevents failures like those reported in
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/34173.

We have enabled the default contructor for
`llvm::ElementCount`. Limiting the use of the contructor for
`{unsigned, bool}` initialization is enough to make sure that the
users of `llvm::ElementCount` are aware of the type of instance they
are using.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86240

Files:
  llvm/include/llvm/IR/Intrinsics.h
  llvm/include/llvm/Support/TypeSize.h


Index: llvm/include/llvm/Support/TypeSize.h
===================================================================
--- llvm/include/llvm/Support/TypeSize.h
+++ llvm/include/llvm/Support/TypeSize.h
@@ -35,10 +35,6 @@
   ElementCount(unsigned Min, bool Scalable) : Min(Min), Scalable(Scalable) {}
 
 public:
-  /// No default constructor. Users should use one of the `get*`
-  /// static methods below, as they should always make a conscious
-  /// choice on the type of `ElementCount` they are requesting.
-  ElementCount() = delete;
   unsigned Min;  // Minimum number of vector elements.
   bool Scalable; // If true, NumElements is a multiple of 'Min' determined
                  // at runtime rather than compile time.
Index: llvm/include/llvm/IR/Intrinsics.h
===================================================================
--- llvm/include/llvm/IR/Intrinsics.h
+++ llvm/include/llvm/IR/Intrinsics.h
@@ -134,9 +134,7 @@
       unsigned Pointer_AddressSpace;
       unsigned Struct_NumElements;
       unsigned Argument_Info;
-      // There is no default constructor in `ElementCount`, so we need
-      // to explicitly initialize this field with a value.
-      ElementCount Vector_Width = ElementCount::getFixed(0);
+      ElementCount Vector_Width;
     };
 
     enum ArgKind {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86240.286639.patch
Type: text/x-patch
Size: 1288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200819/62553274/attachment.bin>


More information about the llvm-commits mailing list