[llvm] 9803db8 - [NFC] Remove dead code

Guillaume Chatelet via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 06:13:10 PDT 2022


Author: Guillaume Chatelet
Date: 2022-06-22T13:13:01Z
New Revision: 9803db8c18cf15266e4bd5faa4ef0ccf65f89ceb

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

LOG: [NFC] Remove dead code

Added: 
    

Modified: 
    llvm/include/llvm/Support/Alignment.h
    llvm/unittests/Support/AlignmentTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/Alignment.h b/llvm/include/llvm/Support/Alignment.h
index b5a5f18405a6..0b1d52061f2c 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 f9490c6e629a..0514db28a243 100644
--- a/llvm/unittests/Support/AlignmentTest.cpp
+++ b/llvm/unittests/Support/AlignmentTest.cpp
@@ -50,9 +50,7 @@ std::vector<uint64_t> 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);
   }
 }
 


        


More information about the llvm-commits mailing list