Skip to content

Commit 4ddc216

Browse files
committed
Revert "[Alignment][NFC] Allow constexpr Align"
This reverts commit b3af236. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373619 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 36e56a1 commit 4ddc216

File tree

5 files changed

+5
-61
lines changed

5 files changed

+5
-61
lines changed

include/llvm/Support/Alignment.h

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ struct Align {
5858
constexpr Align() = default;
5959
/// Do not perform checks in case of copy/move construct/assign, because the
6060
/// checks have been performed when building `Other`.
61-
constexpr Align(const Align &Other) = default;
62-
constexpr Align &operator=(const Align &Other) = default;
63-
constexpr Align(Align &&Other) = default;
64-
constexpr Align &operator=(Align &&Other) = default;
61+
Align(const Align &Other) = default;
62+
Align &operator=(const Align &Other) = default;
63+
Align(Align &&Other) = default;
64+
Align &operator=(Align &&Other) = default;
6565

6666
explicit Align(uint64_t Value) {
6767
assert(Value > 0 && "Value must not be 0");
@@ -80,24 +80,6 @@ struct Align {
8080
/// would be better than
8181
/// `if (A > Align(1))`
8282
constexpr static const Align None() { return Align(); }
83-
84-
/// This function is useful when initializing constexpr Align constants.
85-
/// e.g. static constexpr Align kAlign16 = Align::Constant<16>();
86-
/// Most compilers (clang, gcc, icc) will be able to compute `ShiftValue`
87-
/// at compile time with `Align::Align(uint64_t Value)` but to be
88-
/// able to use Align as a constexpr constant use this method.
89-
/// FIXME: When LLVM is C++17 ready `Align::Align(uint64_t Value)`
90-
/// can be constexpr and we can dispatch between runtime (Log2_64) vs
91-
/// compile time (CTLog2) versions using constexpr-if. Then this
92-
/// function is no more necessary and we can add user defined literals
93-
/// for convenience.
94-
template <uint64_t kValue> constexpr static Align Constant() {
95-
static_assert(kValue > 0 && llvm::isPowerOf2_64(kValue),
96-
"Not a valid alignment");
97-
Align A;
98-
A.ShiftValue = CTLog2<kValue>();
99-
return A;
100-
}
10183
};
10284

10385
/// Treats the value 0 as a 1, so Align is always at least 1.

include/llvm/Support/MathExtras.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -532,15 +532,6 @@ inline double Log2(double Value) {
532532
#endif
533533
}
534534

535-
/// Return the compile time log base 2 of the specified Value.
536-
/// `kValue` has to be a power of two.
537-
template <uint64_t kValue> static constexpr inline uint8_t CTLog2() {
538-
static_assert(kValue > 0 && llvm::isPowerOf2_64(kValue),
539-
"Value is not a valid power of 2");
540-
return 1 + CTLog2<kValue / 2>();
541-
}
542-
template <> constexpr inline uint8_t CTLog2<1>() { return 0; }
543-
544535
/// Return the floor log base 2 of the specified value, -1 if the value is zero.
545536
/// (32 bit edition.)
546537
/// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2

lib/Target/AArch64/AArch64StackTagging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static cl::opt<bool> ClMergeInit(
6262
static cl::opt<unsigned> ClScanLimit("stack-tagging-merge-init-scan-limit",
6363
cl::init(40), cl::Hidden);
6464

65-
static constexpr Align kTagGranuleSize = Align::Constant<16>();
65+
static const Align kTagGranuleSize = Align(16);
6666

6767
namespace {
6868

unittests/Support/AlignmentTest.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@ TEST(AlignmentTest, ValidCTors) {
4444
}
4545
}
4646

47-
TEST(AlignmentTest, CompileTimeConstant) {
48-
EXPECT_EQ(Align::Constant<1>(), Align(1));
49-
EXPECT_EQ(Align::Constant<2>(), Align(2));
50-
EXPECT_EQ(Align::Constant<4>(), Align(4));
51-
EXPECT_EQ(Align::Constant<8>(), Align(8));
52-
EXPECT_EQ(Align::Constant<16>(), Align(16));
53-
EXPECT_EQ(Align::Constant<32>(), Align(32));
54-
EXPECT_EQ(Align::Constant<64>(), Align(64));
55-
}
56-
5747
TEST(AlignmentTest, CheckMaybeAlignHasValue) {
5848
EXPECT_TRUE(MaybeAlign(1));
5949
EXPECT_TRUE(MaybeAlign(1).hasValue());

unittests/Support/MathExtrasTest.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -203,25 +203,6 @@ TEST(MathExtras, PowerOf2Floor) {
203203
EXPECT_EQ(4U, PowerOf2Floor(7U));
204204
}
205205

206-
TEST(MathExtras, CTLog2) {
207-
EXPECT_EQ(CTLog2<1ULL << 0>(), 0);
208-
EXPECT_EQ(CTLog2<1ULL << 1>(), 1);
209-
EXPECT_EQ(CTLog2<1ULL << 2>(), 2);
210-
EXPECT_EQ(CTLog2<1ULL << 3>(), 3);
211-
EXPECT_EQ(CTLog2<1ULL << 4>(), 4);
212-
EXPECT_EQ(CTLog2<1ULL << 5>(), 5);
213-
EXPECT_EQ(CTLog2<1ULL << 6>(), 6);
214-
EXPECT_EQ(CTLog2<1ULL << 7>(), 7);
215-
EXPECT_EQ(CTLog2<1ULL << 8>(), 8);
216-
EXPECT_EQ(CTLog2<1ULL << 9>(), 9);
217-
EXPECT_EQ(CTLog2<1ULL << 10>(), 10);
218-
EXPECT_EQ(CTLog2<1ULL << 11>(), 11);
219-
EXPECT_EQ(CTLog2<1ULL << 12>(), 12);
220-
EXPECT_EQ(CTLog2<1ULL << 13>(), 13);
221-
EXPECT_EQ(CTLog2<1ULL << 14>(), 14);
222-
EXPECT_EQ(CTLog2<1ULL << 15>(), 15);
223-
}
224-
225206
TEST(MathExtras, ByteSwap_32) {
226207
EXPECT_EQ(0x44332211u, ByteSwap_32(0x11223344));
227208
EXPECT_EQ(0xDDCCBBAAu, ByteSwap_32(0xAABBCCDD));

0 commit comments

Comments
 (0)