Skip to content

Commit d37642b

Browse files
committed
Simplify address mask setting logic in AddressableBits
I wrote some complicated conditionals for how to handle a partially specified AddressableBits object in https://reviews.llvm.org/D158041 , and how to reuse existing masks if they were set and we had an unspecified value. I don't think this logic is the right thing to start with. Simplify back to the most straightforward setting, where only the bits that have been specified are set in the Process.
1 parent f745c91 commit d37642b

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

lldb/source/Utility/AddressableBits.cpp

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,42 +37,14 @@ void AddressableBits::SetProcessMasks(Process &process) {
3737
if (m_low_memory_addr_bits == 0 && m_high_memory_addr_bits == 0)
3838
return;
3939

40-
// If we don't have an addressable bits value for low memory,
41-
// see if we have a Code/Data mask already, and use that.
42-
// Or use the high memory addressable bits value as a last
43-
// resort.
44-
addr_t low_addr_mask;
45-
if (m_low_memory_addr_bits == 0) {
46-
if (process.GetCodeAddressMask() != UINT64_MAX)
47-
low_addr_mask = process.GetCodeAddressMask();
48-
else if (process.GetDataAddressMask() != UINT64_MAX)
49-
low_addr_mask = process.GetDataAddressMask();
50-
else
51-
low_addr_mask = ~((1ULL << m_high_memory_addr_bits) - 1);
52-
} else {
53-
low_addr_mask = ~((1ULL << m_low_memory_addr_bits) - 1);
40+
if (m_low_memory_addr_bits != 0) {
41+
addr_t low_addr_mask = ~((1ULL << m_low_memory_addr_bits) - 1);
42+
process.SetCodeAddressMask(low_addr_mask);
43+
process.SetDataAddressMask(low_addr_mask);
5444
}
5545

56-
// If we don't have an addressable bits value for high memory,
57-
// see if we have a Code/Data mask already, and use that.
58-
// Or use the low memory addressable bits value as a last
59-
// resort.
60-
addr_t hi_addr_mask;
61-
if (m_high_memory_addr_bits == 0) {
62-
if (process.GetHighmemCodeAddressMask() != UINT64_MAX)
63-
hi_addr_mask = process.GetHighmemCodeAddressMask();
64-
else if (process.GetHighmemDataAddressMask() != UINT64_MAX)
65-
hi_addr_mask = process.GetHighmemDataAddressMask();
66-
else
67-
hi_addr_mask = ~((1ULL << m_low_memory_addr_bits) - 1);
68-
} else {
69-
hi_addr_mask = ~((1ULL << m_high_memory_addr_bits) - 1);
70-
}
71-
72-
process.SetCodeAddressMask(low_addr_mask);
73-
process.SetDataAddressMask(low_addr_mask);
74-
75-
if (low_addr_mask != hi_addr_mask) {
46+
if (m_high_memory_addr_bits != 0) {
47+
addr_t hi_addr_mask = ~((1ULL << m_high_memory_addr_bits) - 1);
7648
process.SetHighmemCodeAddressMask(hi_addr_mask);
7749
process.SetHighmemDataAddressMask(hi_addr_mask);
7850
}

0 commit comments

Comments
 (0)