[BOLT] Make sure IOAddressMap exist before lookup (NFC) (#183184)
`BinaryFunction::translateInputToOutputAddress()` contains fallback logic in case that querying `IOAddressMap` doesn't yield an output address. Because this function could be called in scenarios where `IOAddressMap` won't be set up, we should check if the map actually exists before lookup.
This commit is contained in:
@@ -1560,6 +1560,7 @@ public:
|
||||
return Streamer;
|
||||
}
|
||||
|
||||
bool hasIOAddressMap() const { return IOAddressMap.has_value(); }
|
||||
void setIOAddressMap(AddressMap Map) { IOAddressMap = std::move(Map); }
|
||||
const AddressMap &getIOAddressMap() const {
|
||||
assert(IOAddressMap && "Address map not set yet");
|
||||
|
||||
@@ -4631,8 +4631,10 @@ uint64_t BinaryFunction::translateInputToOutputAddress(uint64_t Address) const {
|
||||
|
||||
// Check if the address is associated with an instruction that is tracked
|
||||
// by address translation.
|
||||
if (auto OutputAddress = BC.getIOAddressMap().lookup(Address))
|
||||
return *OutputAddress;
|
||||
if (BC.hasIOAddressMap()) {
|
||||
if (auto OutputAddress = BC.getIOAddressMap().lookup(Address))
|
||||
return *OutputAddress;
|
||||
}
|
||||
|
||||
// FIXME: #18950828 - we rely on relative offsets inside basic blocks to stay
|
||||
// intact. Instead we can use pseudo instructions and/or annotations.
|
||||
|
||||
Reference in New Issue
Block a user