summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeno Fischer <kfischer@college.harvard.edu>2015-10-10 05:37:02 +0000
committerKeno Fischer <kfischer@college.harvard.edu>2015-10-10 05:37:02 +0000
commit2cd66e9270d922a96f99e249dc4bf9bf8ba32178 (patch)
tree7d2198190fd074731414ea4bd2d8ab9a2d02469a
parent7143d8001a59cf9c4c4747c951dabc8ab59fa137 (diff)
downloadbcm5719-llvm-2cd66e9270d922a96f99e249dc4bf9bf8ba32178.tar.gz
bcm5719-llvm-2cd66e9270d922a96f99e249dc4bf9bf8ba32178.zip
[RuntimeDyld] Fix performance problem in resolveRelocations with many sections
Summary: Rather than just iterating over all sections and checking whether we have relocations for them, iterate over the relocation map instead. This showed up heavily in an artificial julia benchmark that does lots of compilation. On that particular benchmark, this patch gives ~15% performance improvements. As far as I can tell the primary reason why the original loop was so expensive is that Relocations[i] actually constructs a relocationList (allocating memory & doing lots of other unnecessary computing) if none is found. Reviewers: lhames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13545 llvm-svn: 249942
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index a2557cbb055..b2f017c94cb 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -91,18 +91,18 @@ void RuntimeDyldImpl::resolveRelocations() {
// First, resolve relocations associated with external symbols.
resolveExternalSymbols();
- // Just iterate over the sections we have and resolve all the relocations
- // in them. Gross overkill, but it gets the job done.
- for (int i = 0, e = Sections.size(); i != e; ++i) {
+ // Iterate over all outstanding relocations
+ for (auto it = Relocations.begin(), e = Relocations.end(); it != e; ++it) {
// The Section here (Sections[i]) refers to the section in which the
// symbol for the relocation is located. The SectionID in the relocation
// entry provides the section to which the relocation will be applied.
- uint64_t Addr = Sections[i].LoadAddress;
- DEBUG(dbgs() << "Resolving relocations Section #" << i << "\t"
+ int Idx = it->getFirst();
+ uint64_t Addr = Sections[Idx].LoadAddress;
+ DEBUG(dbgs() << "Resolving relocations Section #" << Idx << "\t"
<< format("%p", (uintptr_t)Addr) << "\n");
- resolveRelocationList(Relocations[i], Addr);
- Relocations.erase(i);
+ resolveRelocationList(it->getSecond(), Addr);
}
+ Relocations.clear();
// Print out sections after relocation.
DEBUG(
OpenPOWER on IntegriCloud