[llvm] [PDB] Fix and simplify module index lookup (PR #179869)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 4 22:01:33 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
@llvm/pr-subscribers-platform-windows
Author: Haohai Wen (HaohaiWen)
<details>
<summary>Changes</summary>
The range returned by IntervalMap::find is only guranteed to end after
address queried. We have to check whether queried address is inside this
range.
---
Full diff: https://github.com/llvm/llvm-project/pull/179869.diff
1 Files Affected:
- (modified) llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp (+6-10)
``````````diff
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
index 49674b4c32de0..cfa3328f5f2d6 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
@@ -410,20 +410,16 @@ uint64_t NativeSession::getVAFromSectOffset(uint32_t Section,
bool NativeSession::moduleIndexForVA(uint64_t VA, uint16_t &ModuleIndex) const {
ModuleIndex = 0;
auto Iter = AddrToModuleIndex.find(VA);
- if (Iter == AddrToModuleIndex.end())
- return false;
- ModuleIndex = Iter.value();
- return true;
+ if (Iter.valid() && !IMap::KeyTraits::startLess(VA, Iter.start())) {
+ ModuleIndex = Iter.value();
+ return true;
+ }
+ return false;
}
bool NativeSession::moduleIndexForSectOffset(uint32_t Sect, uint32_t Offset,
uint16_t &ModuleIndex) const {
- ModuleIndex = 0;
- auto Iter = AddrToModuleIndex.find(getVAFromSectOffset(Sect, Offset));
- if (Iter == AddrToModuleIndex.end())
- return false;
- ModuleIndex = Iter.value();
- return true;
+ return moduleIndexForVA(getVAFromSectOffset(Sect, Offset), ModuleIndex);
}
void NativeSession::parseSectionContribs() {
``````````
</details>
https://github.com/llvm/llvm-project/pull/179869
More information about the llvm-commits
mailing list