llvm.org GIT mirror llvm / b9a6adc
Merging r247372 to 3.7 for inclusion in 3.7.1 ------------------------------------------------------------------------ r247372 | dexonsmith | 2015-09-10 18:34:59 -0700 (Thu, 10 Sep 2015) | 15 lines AsmWriter: Avoid O(N^2) processing of metadata Fix embarrassing bugs I introduced to the `SlotTracker` in or around r235785. I had us iterating through every instruction in a function (and hitting a map in the LLVMContext) for every basic block in the function. While there, completely avoid the call to `SlotTracker::processFunctionMetadata()` from `SlotTracker::processFunction()` if we've speculatively done this already in `SlotTracker::processModule()` by checking `ShouldInitializeAllMetadata` (this wasn't an algorithmic problem, but it's touching the same line of code). Fixes PR24699. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@247440 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 4 years ago
1 changed file(s) with 8 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
793793 ST_DEBUG("begin processFunction!\n");
794794 fNext = 0;
795795
796 // Process function metadata if it wasn't hit at the module-level.
797 if (!ShouldInitializeAllMetadata)
798 processFunctionMetadata(*TheFunction);
799
796800 // Add all the function arguments with no names.
797801 for(Function::const_arg_iterator AI = TheFunction->arg_begin(),
798802 AE = TheFunction->arg_end(); AI != AE; ++AI)
805809 for (auto &BB : *TheFunction) {
806810 if (!BB.hasName())
807811 CreateFunctionSlot(&BB);
808
809 processFunctionMetadata(*TheFunction);
810812
811813 for (auto &I : BB) {
812814 if (!I.getType()->isVoidTy() && !I.hasName())
835837
836838 void SlotTracker::processFunctionMetadata(const Function &F) {
837839 SmallVector, 4> MDs;
840 F.getAllMetadata(MDs);
841 for (auto &MD : MDs)
842 CreateMetadataSlot(MD.second);
843
838844 for (auto &BB : F) {
839 F.getAllMetadata(MDs);
840 for (auto &MD : MDs)
841 CreateMetadataSlot(MD.second);
842
843845 for (auto &I : BB)
844846 processInstructionMetadata(I);
845847 }