[clang] Revert "[clang] Increase VecLib bitfield size to 4 bits in CodeGenOptions.def" (PR #109161)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 08:33:54 PDT 2024


https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/109161

Reverts llvm/llvm-project#108804

>From 4cabae1e59f75c9be5a1156cc785c93ece49c531 Mon Sep 17 00:00:00 2001
From: Aaron Ballman <aaron at aaronballman.com>
Date: Wed, 18 Sep 2024 11:33:44 -0400
Subject: [PATCH] =?UTF-8?q?Revert=20"[clang]=20Increase=20VecLib=20bitfiel?=
 =?UTF-8?q?d=20size=20to=204=20bits=20in=20CodeGenOptions.def=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 475ceca859233b387c22f13ecef581158ef36346.
---
 clang/include/clang/Basic/CodeGenOptions.def  | 14 ++--------
 clang/unittests/CodeGen/AllLibrariesFit.cpp   | 10 -------
 .../CodeGen/EncodingDecodingTest.cpp          | 17 ------------
 .../CodeGen/SimulatedOverflowTest.cpp         | 26 -------------------
 4 files changed, 2 insertions(+), 65 deletions(-)
 delete mode 100644 clang/unittests/CodeGen/AllLibrariesFit.cpp
 delete mode 100644 clang/unittests/CodeGen/EncodingDecodingTest.cpp
 delete mode 100644 clang/unittests/CodeGen/SimulatedOverflowTest.cpp

diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def
index b78ae61e6509ea..b600198998d85b 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -375,18 +375,8 @@ ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining)
 /// The maximum stack size a function can have to be considered for inlining.
 VALUE_CODEGENOPT(InlineMaxStackSize, 32, UINT_MAX)
 
-// Define the number of bits required for the VecLib enum
-#define VECLIB_BIT_COUNT (llvm::countPopulation(llvm::driver::VectorLibrary::MaxLibrary))
-
-// Ensure the VecLib bitfield has enough space for future vector libraries.
-// The number of bits is determined automatically based on the number of enum values.
-static_assert(static_cast<size_t>(llvm::driver::VectorLibrary::MaxLibrary) <= (1 << VECLIB_BIT_COUNT),
-              "VecLib bitfield size is too small to accommodate all vector libraries.");
-              
-// VecLib definition in CodeGenOptions.def
-ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, VECLIB_BIT_COUNT, llvm::driver::VectorLibrary::NoLibrary)
-
-#undef VECLIB_BIT_COUNT
+// Vector functions library to use.
+ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, llvm::driver::VectorLibrary::NoLibrary)
 
 /// The default TLS model to use.
 ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
diff --git a/clang/unittests/CodeGen/AllLibrariesFit.cpp b/clang/unittests/CodeGen/AllLibrariesFit.cpp
deleted file mode 100644
index dfe63b557729ee..00000000000000
--- a/clang/unittests/CodeGen/AllLibrariesFit.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "clang/Basic/CodeGenOptions.h"
-#include "llvm/Driver/Options.h"
-#include "gtest/gtest.h"
-
-TEST(VecLibBitfieldTest, AllLibrariesFit) {
-  // We expect that all vector libraries fit in the bitfield size
-  EXPECT_LE(static_cast<size_t>(llvm::driver::VectorLibrary::MaxLibrary),
-            (1 << VECLIB_BIT_COUNT))
-      << "VecLib bitfield size is too small!";
- }
diff --git a/clang/unittests/CodeGen/EncodingDecodingTest.cpp b/clang/unittests/CodeGen/EncodingDecodingTest.cpp
deleted file mode 100644
index 67c89ef07c428b..00000000000000
--- a/clang/unittests/CodeGen/EncodingDecodingTest.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-TEST(VecLibBitfieldTest, EncodingDecodingTest) {
-  clang::CodeGenOptions Opts;
-
-  // Test encoding and decoding for each vector library
-  for (int i = static_cast<int>(llvm::driver::VectorLibrary::Accelerate);
-       i <= static_cast<int>(llvm::driver::VectorLibrary::MaxLibrary); ++i) {
-
-    Opts.VecLib = static_cast<llvm::driver::VectorLibrary>(i);
-
-    // Encode and then decode
-    llvm::driver::VectorLibrary decodedValue =
-        static_cast<llvm::driver::VectorLibrary>(Opts.VecLib);
-
-    EXPECT_EQ(decodedValue, Opts.VecLib)
-        << "Encoding/Decoding failed for vector library " << i;
-  }
-}
diff --git a/clang/unittests/CodeGen/SimulatedOverflowTest.cpp b/clang/unittests/CodeGen/SimulatedOverflowTest.cpp
deleted file mode 100644
index acfeaf7498b6d0..00000000000000
--- a/clang/unittests/CodeGen/SimulatedOverflowTest.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-// Simulate the addition of a new library without increasing the bitfield size
-enum class SimulatedVectorLibrary {
-  Accelerate = 0,
-  LIBMVEC,
-  MASSV,
-  SVML,
-  SLEEF,
-  Darwin_libsystem_m,
-  ArmPL,
-  AMDLIBM,
-  NoLibrary,
-  // Simulate new addition
-  NewLibrary,
-  MaxLibrary
-};
-
-#define SIMULATED_VECLIB_BIT_COUNT                                             \
-  4 // The current bitfield size (should be 4 for 9 options)
-
-TEST(VecLibBitfieldTest, SimulatedOverflowTest) {
-  // Simulate the addition of a new library and check if the bitfield size is
-  // sufficient
-  EXPECT_LE(static_cast<size_t>(SimulatedVectorLibrary::MaxLibrary),
-            (1 << SIMULATED_VECLIB_BIT_COUNT))
-      << "Simulated VecLib bitfield size overflow!";
-}



More information about the cfe-commits mailing list