[llvm] dac0b1d - [llvm] Add default constructor of `llvm::ElementCount`.

Francesco Petrogalli via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 14:40:26 PDT 2020


Author: Francesco Petrogalli
Date: 2020-08-19T21:39:24Z
New Revision: dac0b1d33088429cdaf795e81e8576288460c67d

URL: https://github.com/llvm/llvm-project/commit/dac0b1d33088429cdaf795e81e8576288460c67d
DIFF: https://github.com/llvm/llvm-project/commit/dac0b1d33088429cdaf795e81e8576288460c67d.diff

LOG: [llvm] Add default constructor of `llvm::ElementCount`.

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 constructor for
`llvm::ElementCount` to make sure the code compiles on Windows.

Reviewed By: ormris

Differential Revision: https://reviews.llvm.org/D86240

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Intrinsics.h b/llvm/include/llvm/IR/Intrinsics.h
index 3fc7c5a2ceb4..f68c834e4cf6 100644
--- a/llvm/include/llvm/IR/Intrinsics.h
+++ b/llvm/include/llvm/IR/Intrinsics.h
@@ -134,9 +134,7 @@ namespace Intrinsic {
       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 {

diff  --git a/llvm/include/llvm/Support/TypeSize.h b/llvm/include/llvm/Support/TypeSize.h
index a95d38863035..a7f5b849bcc1 100644
--- a/llvm/include/llvm/Support/TypeSize.h
+++ b/llvm/include/llvm/Support/TypeSize.h
@@ -35,14 +35,12 @@ class ElementCount {
   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.
 
+  ElementCount() = default;
+
   ElementCount operator*(unsigned RHS) {
     return { Min * RHS, Scalable };
   }


        


More information about the llvm-commits mailing list