[llvm] 1baf1fc - [NFC] Remove dead code
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 25 10:18:55 PDT 2022
Author: Guillaume Chatelet
Date: 2022-06-25T17:18:45Z
New Revision: 1baf1fc27640b6e4b7a83484f4d99e7e6dbee571
URL: https://github.com/llvm/llvm-project/commit/1baf1fc27640b6e4b7a83484f4d99e7e6dbee571
DIFF: https://github.com/llvm/llvm-project/commit/1baf1fc27640b6e4b7a83484f4d99e7e6dbee571.diff
LOG: [NFC] Remove dead code
Added:
Modified:
llvm/include/llvm/Support/Alignment.h
llvm/unittests/IR/AttributesTest.cpp
llvm/unittests/Support/AlignmentTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/Alignment.h b/llvm/include/llvm/Support/Alignment.h
index 0b1d52061f2c5..2a1d6a33d3fcb 100644
--- a/llvm/include/llvm/Support/Alignment.h
+++ b/llvm/include/llvm/Support/Alignment.h
@@ -260,14 +260,6 @@ inline bool operator>(Align Lhs, uint64_t Rhs) {
return Lhs.value() > Rhs;
}
-/// Comparisons between MaybeAlign and scalars.
-inline bool operator==(MaybeAlign Lhs, uint64_t Rhs) {
- return Lhs ? (*Lhs).value() == Rhs : Rhs == 0;
-}
-inline bool operator!=(MaybeAlign Lhs, uint64_t Rhs) {
- return Lhs ? (*Lhs).value() != Rhs : Rhs != 0;
-}
-
/// Comparisons operators between Align.
inline bool operator==(Align Lhs, Align Rhs) {
return Lhs.ShiftValue == Rhs.ShiftValue;
diff --git a/llvm/unittests/IR/AttributesTest.cpp b/llvm/unittests/IR/AttributesTest.cpp
index cacb12df0c3d1..eabaad424f9ec 100644
--- a/llvm/unittests/IR/AttributesTest.cpp
+++ b/llvm/unittests/IR/AttributesTest.cpp
@@ -90,14 +90,14 @@ TEST(Attributes, RemoveAlign) {
B_stackalign.addAttribute(StackAlignAttr);
AttributeSet AS = AttributeSet::get(C, B_align_readonly);
- EXPECT_TRUE(AS.getAlignment() == 8);
+ EXPECT_TRUE(AS.getAlignment() == MaybeAlign(8));
EXPECT_TRUE(AS.hasAttribute(Attribute::ReadOnly));
AS = AS.removeAttribute(C, Attribute::Alignment);
EXPECT_FALSE(AS.hasAttribute(Attribute::Alignment));
EXPECT_TRUE(AS.hasAttribute(Attribute::ReadOnly));
AS = AttributeSet::get(C, B_align_readonly);
AS = AS.removeAttributes(C, B_align);
- EXPECT_TRUE(AS.getAlignment() == 0);
+ EXPECT_TRUE(AS.getAlignment() == None);
EXPECT_TRUE(AS.hasAttribute(Attribute::ReadOnly));
AttributeList AL;
@@ -106,18 +106,18 @@ TEST(Attributes, RemoveAlign) {
EXPECT_TRUE(AL.hasRetAttrs());
EXPECT_TRUE(AL.hasRetAttr(Attribute::StackAlignment));
EXPECT_TRUE(AL.hasRetAttr(Attribute::OptimizeNone));
- EXPECT_TRUE(AL.getRetStackAlignment() == 32);
+ EXPECT_TRUE(AL.getRetStackAlignment() == MaybeAlign(32));
EXPECT_TRUE(AL.hasParamAttrs(0));
EXPECT_TRUE(AL.hasParamAttr(0, Attribute::Alignment));
EXPECT_TRUE(AL.hasParamAttr(0, Attribute::ReadOnly));
- EXPECT_TRUE(AL.getParamAlignment(0) == 8);
+ EXPECT_TRUE(AL.getParamAlignment(0) == MaybeAlign(8));
AL = AL.removeParamAttribute(C, 0, Attribute::Alignment);
EXPECT_FALSE(AL.hasParamAttr(0, Attribute::Alignment));
EXPECT_TRUE(AL.hasParamAttr(0, Attribute::ReadOnly));
EXPECT_TRUE(AL.hasRetAttr(Attribute::StackAlignment));
EXPECT_TRUE(AL.hasRetAttr(Attribute::OptimizeNone));
- EXPECT_TRUE(AL.getRetStackAlignment() == 32);
+ EXPECT_TRUE(AL.getRetStackAlignment() == MaybeAlign(32));
AL = AL.removeRetAttribute(C, Attribute::StackAlignment);
EXPECT_FALSE(AL.hasParamAttr(0, Attribute::Alignment));
@@ -134,7 +134,7 @@ TEST(Attributes, RemoveAlign) {
EXPECT_TRUE(AL2.hasParamAttr(0, Attribute::ReadOnly));
EXPECT_TRUE(AL2.hasRetAttr(Attribute::StackAlignment));
EXPECT_TRUE(AL2.hasRetAttr(Attribute::OptimizeNone));
- EXPECT_TRUE(AL2.getRetStackAlignment() == 32);
+ EXPECT_TRUE(AL2.getRetStackAlignment() == MaybeAlign(32));
AL2 = AL2.removeRetAttributes(C, B_stackalign);
EXPECT_FALSE(AL2.hasParamAttr(0, Attribute::Alignment));
diff --git a/llvm/unittests/Support/AlignmentTest.cpp b/llvm/unittests/Support/AlignmentTest.cpp
index 0514db28a243c..cb89776c0b7ae 100644
--- a/llvm/unittests/Support/AlignmentTest.cpp
+++ b/llvm/unittests/Support/AlignmentTest.cpp
@@ -227,9 +227,6 @@ TEST(AlignmentTest, AlignComparisons) {
EXPECT_EQ(MA, MA);
EXPECT_NE(MA, MB);
- EXPECT_EQ(MA, MA ? (*MA).value() : 0);
- EXPECT_NE(MA, MB ? (*MB).value() : 0);
-
EXPECT_EQ(std::max(A, B), B);
EXPECT_EQ(std::min(A, B), A);
}
@@ -277,14 +274,6 @@ TEST(AlignmentDeathTest, ComparisonsWithZero) {
}
}
-TEST(AlignmentDeathTest, CompareMaybeAlignToZero) {
- for (uint64_t Value : getValidAlignmentsForDeathTest()) {
- // MaybeAlign is allowed to be == or != 0
- (void)(MaybeAlign(Value) == 0);
- (void)(MaybeAlign(Value) != 0);
- }
-}
-
TEST(AlignmentDeathTest, AlignAddr) {
const void *const unaligned_high_ptr =
reinterpret_cast<const void *>(std::numeric_limits<uintptr_t>::max() - 1);
More information about the llvm-commits
mailing list