[Mlir-commits] [mlir] e459596 - Temporarily Revert "[mlir] Add padding to 1-D Vector in CRunnerUtils.h"

Eric Christopher llvmlistbot at llvm.org
Mon Mar 2 14:47:32 PST 2020


Author: Eric Christopher
Date: 2020-03-02T14:47:21-08:00
New Revision: e459596917a72f11bd8251a81bdb521401abdd3d

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

LOG: Temporarily Revert "[mlir] Add padding to 1-D Vector in CRunnerUtils.h"
as it broke the Werror build:

.../sources/llvm-project/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h:85:16: error: zero size arrays are an extension [-Werror,-Wzero-length-array]
  char padding[detail::nextPowerOf2<sizeof(T[Dim])>() - sizeof(T[Dim])];
               ^~~~~~~~~~~~~~~

This reverts commit 78f9e5d098af95610f4542ee41479d7931261066.

Added: 
    

Modified: 
    mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
    mlir/include/mlir/ExecutionEngine/RunnerUtils.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h b/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
index d39806028c28..d82963b1aa03 100644
--- a/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
@@ -39,50 +39,14 @@ template <int N> void dropFront(int64_t arr[N], int64_t *res) {
 //===----------------------------------------------------------------------===//
 // Codegen-compatible structures for Vector type.
 //===----------------------------------------------------------------------===//
-namespace detail {
-  template <unsigned N>
-  constexpr unsigned nextPowerOf2();
-  template <>
-  constexpr unsigned nextPowerOf2<0>() {
-    return 1;
-  }
-  template <>
-  constexpr unsigned nextPowerOf2<1>() {
-    return 1;
-  }
-  template <unsigned N>
-  constexpr unsigned nextPowerOf2() {
-    return (!(N & (N - 1))) ? N : 2 * nextPowerOf2<(N + 1) / 2>();
-  }
-} // end namespace detail
-
-// N-D vectors recurse down to 1-D.
 template <typename T, int Dim, int... Dims>
 struct Vector {
-  constexpr Vector<T, Dims...> &operator[](unsigned i) { return vector[i]; }
-  constexpr const Vector<T, Dims...> &operator[](unsigned i) const {
-    return vector[i];
-  }
-
-private:
   Vector<T, Dims...> vector[Dim];
 };
 
-// 1-D vectors in LLVM are automatically padded to the next power of 2.
-// We insert explicit padding in to account for this.
-template <typename T, int Dim> struct Vector<T, Dim> {
-  Vector() {
-    static_assert(detail::nextPowerOf2<sizeof(T[Dim])>() >= sizeof(T[Dim]),
-                  "size error");
-    static_assert(detail::nextPowerOf2<sizeof(T[Dim])>() < 2 * sizeof(T[Dim]),
-                  "size error");
-  }
-  constexpr T &operator[](unsigned i) { return vector[i]; }
-  constexpr const T &operator[](unsigned i) const { return vector[i]; }
-
-private:
+template <typename T, int Dim>
+struct Vector<T, Dim> {
   T vector[Dim];
-  char padding[detail::nextPowerOf2<sizeof(T[Dim])>() - sizeof(T[Dim])];
 };
 
 template <int D1, typename T>

diff  --git a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
index 16dc54f20da7..2676e648930c 100644
--- a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
@@ -92,7 +92,7 @@ void VectorDataPrinter<T, M, Dims...>::print(std::ostream &os,
   static_assert(sizeof(val) == M * StaticSizeMult<Dims...>::value * sizeof(T),
                 "Incorrect vector size!");
   // First
-  os << "(" << val[0];
+  os << "(" << val.vector[0];
   if (M > 1)
     os << ", ";
   if (sizeof...(Dims) > 1)
@@ -100,14 +100,14 @@ void VectorDataPrinter<T, M, Dims...>::print(std::ostream &os,
   // Kernel
   for (unsigned i = 1; i + 1 < M; ++i) {
     printSpace(os, 2 * sizeof...(Dims));
-    os << val[i] << ", ";
+    os << val.vector[i] << ", ";
     if (sizeof...(Dims) > 1)
       os << "\n";
   }
   // Last
   if (M > 1) {
     printSpace(os, sizeof...(Dims));
-    os << val[M - 1];
+    os << val.vector[M - 1];
   }
   os << ")";
 }


        


More information about the Mlir-commits mailing list