From 9803db8c18cf15266e4bd5faa4ef0ccf65f89ceb Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Wed, 22 Jun 2022 13:11:30 +0000 Subject: [PATCH] [NFC] Remove dead code --- llvm/include/llvm/Support/Alignment.h | 12 ----------- llvm/unittests/Support/AlignmentTest.cpp | 34 ++++---------------------------- 2 files changed, 4 insertions(+), 42 deletions(-) diff --git a/llvm/include/llvm/Support/Alignment.h b/llvm/include/llvm/Support/Alignment.h index b5a5f18..0b1d520 100644 --- a/llvm/include/llvm/Support/Alignment.h +++ b/llvm/include/llvm/Support/Alignment.h @@ -218,18 +218,6 @@ inline Align commonAlignment(Align A, uint64_t Offset) { return Align(MinAlign(A.value(), Offset)); } -/// Returns the alignment that satisfies both alignments. -/// Same semantic as MinAlign. -inline MaybeAlign commonAlignment(MaybeAlign A, MaybeAlign B) { - return A && B ? commonAlignment(*A, *B) : A ? A : B; -} - -/// Returns the alignment that satisfies both alignments. -/// Same semantic as MinAlign. -inline MaybeAlign commonAlignment(MaybeAlign A, uint64_t Offset) { - return MaybeAlign(MinAlign((*A).value(), Offset)); -} - /// Returns a representation of the alignment that encodes undefined as 0. inline unsigned encode(MaybeAlign A) { return A ? A->ShiftValue + 1 : 0; } diff --git a/llvm/unittests/Support/AlignmentTest.cpp b/llvm/unittests/Support/AlignmentTest.cpp index f9490c6..0514db2 100644 --- a/llvm/unittests/Support/AlignmentTest.cpp +++ b/llvm/unittests/Support/AlignmentTest.cpp @@ -50,9 +50,7 @@ std::vector getValidAlignments() { return Out; } -TEST(AlignmentTest, AlignDefaultCTor) { - EXPECT_EQ(Align().value(), 1ULL); -} +TEST(AlignmentTest, AlignDefaultCTor) { EXPECT_EQ(Align().value(), 1ULL); } TEST(AlignmentTest, MaybeAlignDefaultCTor) { EXPECT_FALSE(MaybeAlign().hasValue()); @@ -94,18 +92,8 @@ TEST(AlignmentTest, AlignTo) { } } kTests[] = { // Align - {1, 0, 0}, - {1, 1, 1}, - {1, 5, 5}, - {2, 0, 0}, - {2, 1, 2}, - {2, 2, 2}, - {2, 7, 8}, - {2, 16, 16}, - {4, 0, 0}, - {4, 1, 4}, - {4, 4, 4}, - {4, 6, 8}, + {1, 0, 0}, {1, 1, 1}, {1, 5, 5}, {2, 0, 0}, {2, 1, 2}, {2, 2, 2}, + {2, 7, 8}, {2, 16, 16}, {4, 0, 0}, {4, 1, 4}, {4, 4, 4}, {4, 6, 8}, }; for (const auto &T : kTests) { Align A = Align(T.alignment); @@ -133,26 +121,12 @@ TEST(AlignmentTest, MinAlign) { uint64_t B; uint64_t MinAlign; } kTests[] = { - // MaybeAlign - {0, 0, 0}, - {0, 8, 8}, - {2, 0, 2}, - // MaybeAlign / Align {1, 2, 1}, {8, 4, 4}, }; for (const auto &T : kTests) { - EXPECT_EQ(commonAlignment(MaybeAlign(T.A), MaybeAlign(T.B)), T.MinAlign); EXPECT_EQ(MinAlign(T.A, T.B), T.MinAlign); - if (T.A) { - EXPECT_EQ(commonAlignment(Align(T.A), MaybeAlign(T.B)), T.MinAlign); - } - if (T.B) { - EXPECT_EQ(commonAlignment(MaybeAlign(T.A), Align(T.B)), T.MinAlign); - } - if (T.A && T.B) { - EXPECT_EQ(commonAlignment(Align(T.A), Align(T.B)), T.MinAlign); - } + EXPECT_EQ(commonAlignment(Align(T.A), Align(T.B)), T.MinAlign); } } -- 2.7.4