[llvm] r358376 - [DWARF] Fix DWARFVerifier::DieRangeInfo::intersects
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 15 01:30:10 PDT 2019
Author: maskray
Date: Mon Apr 15 01:30:10 2019
New Revision: 358376
URL: http://llvm.org/viewvc/llvm-project?rev=358376&view=rev
Log:
[DWARF] Fix DWARFVerifier::DieRangeInfo::intersects
It was incorrect if RHS had more than 1 ranges and one of the ranges interacted with *this
Modified:
llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=358376&r1=358375&r2=358376&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp Mon Apr 15 01:30:10 2019
@@ -85,23 +85,16 @@ bool DWARFVerifier::DieRangeInfo::contai
}
bool DWARFVerifier::DieRangeInfo::intersects(const DieRangeInfo &RHS) const {
- if (Ranges.empty() || RHS.Ranges.empty())
- return false;
-
- auto End = Ranges.end();
- auto Iter = findRange(RHS.Ranges.front());
- for (const auto &R : RHS.Ranges) {
- if (Iter == End)
- return false;
- if (R.HighPC <= Iter->LowPC)
- continue;
- while (Iter != End) {
- if (Iter->intersects(R))
- return true;
- ++Iter;
- }
+ auto I1 = Ranges.begin(), E1 = Ranges.end();
+ auto I2 = RHS.Ranges.begin(), E2 = RHS.Ranges.end();
+ while (I1 != E1 && I2 != E2) {
+ if (I1->intersects(*I2))
+ return true;
+ if (I1->LowPC < I2->LowPC)
+ ++I1;
+ else
+ ++I2;
}
-
return false;
}
Modified: llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp?rev=358376&r1=358375&r2=358376&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp Mon Apr 15 01:30:10 2019
@@ -3188,6 +3188,9 @@ TEST(DWARFDebugInfo, TestDWARFDieRangeIn
AssertRangesIntersect(Ranges, {{0x3f, 0x40}});
// Test range that starts at end of second range
AssertRangesDontIntersect(Ranges, {{0x40, 0x41}});
+
+ AssertRangesDontIntersect(Ranges, {{0x20, 0x21}, {0x2f, 0x30}});
+ AssertRangesIntersect(Ranges, {{0x20, 0x21}, {0x2f, 0x31}});
}
} // end anonymous namespace
More information about the llvm-commits
mailing list