[llvm] d3cf49e - [Alignment] Remove alignTo version taking a MaybeAlign
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 08:16:10 PDT 2022
Author: Guillaume Chatelet
Date: 2022-06-20T15:15:53Z
New Revision: d3cf49e984c12981f7d6df1c47b60fbeb71092ab
URL: https://github.com/llvm/llvm-project/commit/d3cf49e984c12981f7d6df1c47b60fbeb71092ab
DIFF: https://github.com/llvm/llvm-project/commit/d3cf49e984c12981f7d6df1c47b60fbeb71092ab.diff
LOG: [Alignment] Remove alignTo version taking a MaybeAlign
Added:
Modified:
llvm/include/llvm/Support/Alignment.h
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/unittests/Support/AlignmentTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/Alignment.h b/llvm/include/llvm/Support/Alignment.h
index abc12847c2ef4..c6ec976d84166 100644
--- a/llvm/include/llvm/Support/Alignment.h
+++ b/llvm/include/llvm/Support/Alignment.h
@@ -184,12 +184,6 @@ inline uint64_t alignTo(uint64_t Size, Align A, uint64_t Skew) {
return alignTo(Size - Skew, A) + Skew;
}
-/// Returns a multiple of A needed to store `Size` bytes.
-/// Returns `Size` if current alignment is undefined.
-inline uint64_t alignTo(uint64_t Size, MaybeAlign A) {
- return A ? alignTo(Size, A.getValue()) : Size;
-}
-
/// Aligns `Addr` to `Alignment` bytes, rounding up.
inline uintptr_t alignAddr(const void *Addr, Align Alignment) {
uintptr_t ArithAddr = reinterpret_cast<uintptr_t>(Addr);
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index a0f19bd3cf5fe..96c585e71f264 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -648,7 +648,7 @@ STATISTIC(ObjectVisitorLoad,
APInt ObjectSizeOffsetVisitor::align(APInt Size, MaybeAlign Alignment) {
if (Options.RoundToAlign && Alignment)
- return APInt(IntTyBits, alignTo(Size.getZExtValue(), Alignment));
+ return APInt(IntTyBits, alignTo(Size.getZExtValue(), *Alignment));
return Size;
}
diff --git a/llvm/unittests/Support/AlignmentTest.cpp b/llvm/unittests/Support/AlignmentTest.cpp
index f5f0d5e31bee9..f9490c6e629a7 100644
--- a/llvm/unittests/Support/AlignmentTest.cpp
+++ b/llvm/unittests/Support/AlignmentTest.cpp
@@ -93,11 +93,7 @@ TEST(AlignmentTest, AlignTo) {
return reinterpret_cast<const void *>(offset);
}
} kTests[] = {
- // MaybeAlign
- {0, 0, 0},
- {0, 1, 1},
- {0, 5, 5},
- // MaybeAlign / Align
+ // Align
{1, 0, 0},
{1, 1, 1},
{1, 5, 5},
@@ -112,14 +108,9 @@ TEST(AlignmentTest, AlignTo) {
{4, 6, 8},
};
for (const auto &T : kTests) {
- MaybeAlign A(T.alignment);
- // Test MaybeAlign
+ Align A = Align(T.alignment);
EXPECT_EQ(alignTo(T.offset, A), T.rounded);
- // Test Align
- if (A) {
- EXPECT_EQ(alignTo(T.offset, A.getValue()), T.rounded);
- EXPECT_EQ(alignAddr(T.forgedAddr(), A.getValue()), T.rounded);
- }
+ EXPECT_EQ(alignAddr(T.forgedAddr(), A), T.rounded);
}
}
More information about the llvm-commits
mailing list