Skip to content

Commit 5c3ef62

Browse files
[lldb] Use llvm::bit_ceil (NFC) (llvm#138723)
This patch replaces a local implementation of bit_ceil with llvm::bit_ceil. Technically, the local implementation evaluates to 0 on input 0, whereas llvm::bit_ceil evaluates to 1, but that doesn't matter because we have: // Can't watch zero bytes. if (user_size == 0) return {};
1 parent cf9b4d1 commit 5c3ef62

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

lldb/source/Breakpoint/WatchpointAlgorithms.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@ WatchpointAlgorithms::AtomizeWatchpointRequest(
5858
return resources;
5959
}
6060

61-
// This should be `std::bit_ceil(aligned_size)` but
62-
// that requires C++20.
63-
// Calculates the smallest integral power of two that is not smaller than x.
64-
static uint64_t bit_ceil(uint64_t input) {
65-
if (input <= 1 || llvm::popcount(input) == 1)
66-
return input;
67-
68-
return 1ULL << (64 - llvm::countl_zero(input));
69-
}
70-
7161
/// Convert a user's watchpoint request (\a user_addr and \a user_size)
7262
/// into hardware watchpoints, for a target that can watch a power-of-2
7363
/// region of memory (1, 2, 4, 8, etc), aligned to that same power-of-2
@@ -102,7 +92,7 @@ WatchpointAlgorithms::PowerOf2Watchpoints(addr_t user_addr, size_t user_size,
10292
/// Round up \a user_size to the next power-of-2 size
10393
/// user_size == 8 -> aligned_size == 8
10494
/// user_size == 9 -> aligned_size == 16
105-
aligned_size = bit_ceil(aligned_size);
95+
aligned_size = llvm::bit_ceil(aligned_size);
10696

10797
addr_t aligned_start = user_addr & ~(aligned_size - 1);
10898

0 commit comments

Comments
 (0)