[lld] r260437 - Use ArrayRef instead of deep copies of CompactUnwindEntries. NFC.
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 10 13:32:25 PST 2016
Author: pete
Date: Wed Feb 10 15:32:24 2016
New Revision: 260437
URL: http://llvm.org/viewvc/llvm-project?rev=260437&view=rev
Log:
Use ArrayRef instead of deep copies of CompactUnwindEntries. NFC.
We have a vector of all of the compact unwind entries anyway, and
its live as long as we need it to be. So instead of copying from that
vector to another, just take references to the range of the original vector
we need for each compact unwind page.
Modified:
lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
Modified: lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp?rev=260437&r1=260436&r2=260437&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp Wed Feb 10 15:32:24 2016
@@ -59,7 +59,7 @@ struct CompactUnwindEntry {
};
struct UnwindInfoPage {
- std::vector<CompactUnwindEntry> entries;
+ ArrayRef<CompactUnwindEntry> entries;
};
}
@@ -179,7 +179,7 @@ public:
}
// Finally, write out the final sentinel index
- CompactUnwindEntry &finalEntry = pages[pages.size() - 1].entries.back();
+ auto &finalEntry = pages[pages.size() - 1].entries.back();
addImageReference(_topLevelIndexOffset +
3 * pages.size() * sizeof(uint32_t),
finalEntry.rangeStart, finalEntry.rangeLength);
@@ -323,26 +323,23 @@ private:
// boundaries. That might be worth doing, or perhaps we could perform some
// minor balancing for expected number of lookups.
std::vector<UnwindInfoPage> pages;
- unsigned pageStart = 0;
+ auto remainingInfos = llvm::makeArrayRef(unwindInfos);
do {
pages.push_back(UnwindInfoPage());
// FIXME: we only create regular pages at the moment. These can hold up to
// 1021 entries according to the documentation.
- unsigned entriesInPage =
- std::min(1021U, (unsigned)unwindInfos.size() - pageStart);
+ unsigned entriesInPage = std::min(1021U, (unsigned)remainingInfos.size());
- std::copy(unwindInfos.begin() + pageStart,
- unwindInfos.begin() + pageStart + entriesInPage,
- std::back_inserter(pages.back().entries));
- pageStart += entriesInPage;
+ pages.back().entries = remainingInfos.slice(0, entriesInPage);
+ remainingInfos = remainingInfos.slice(entriesInPage);
DEBUG(llvm::dbgs()
<< " Page from " << pages.back().entries[0].rangeStart->name()
<< " to " << pages.back().entries.back().rangeStart->name() << " + "
<< llvm::format("0x%x", pages.back().entries.back().rangeLength)
<< " has " << entriesInPage << " entries\n");
- } while (pageStart < unwindInfos.size());
+ } while (!remainingInfos.empty());
auto *unwind = new (_file.allocator())
UnwindInfoAtom(_archHandler, _file, _isBig, personalities,
More information about the llvm-commits
mailing list