llvm.org GIT mirror llvm / d432c4a
Only seek once before writing the member offsets. This cuts down the number on system calls done by a static llvm-ar producing lib/libclangSema.a from 9164 to 442. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224025 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
1 changed file(s) with 20 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
684684 Out.seek(Pos);
685685 }
686686
687 static void
688 writeSymbolTable(raw_fd_ostream &Out, ArrayRef Members,
689 ArrayRef Buffers,
690 std::vector> &MemberOffsetRefs) {
687 // Returns the offset of the first reference to a member offset.
688 static unsigned writeSymbolTable(raw_fd_ostream &Out,
689 ArrayRef Members,
690 ArrayRef Buffers,
691 std::vector &MemberOffsetRefs) {
691692 unsigned StartOffset = 0;
692693 unsigned MemberNum = 0;
693694 std::string NameBuf;
722723 failIfError(S.printName(NameOS));
723724 NameOS << '\0';
724725 ++NumSyms;
725 MemberOffsetRefs.push_back(std::make_pair(Out.tell(), MemberNum));
726 MemberOffsetRefs.push_back(MemberNum);
726727 print32BE(Out, 0);
727728 }
728729 }
729730 Out << NameOS.str();
730731
731732 if (StartOffset == 0)
732 return;
733 return 0;
733734
734735 if (Out.tell() % 2)
735736 Out << '\0';
740741 Out.seek(StartOffset);
741742 print32BE(Out, NumSyms);
742743 Out.seek(Pos);
744 return StartOffset + 4;
743745 }
744746
745747 static void
754756 raw_fd_ostream &Out = Output.os();
755757 Out << "!\n";
756758
757 std::vector<std::pair > MemberOffsetRefs;
759 std::vector<unsigned> MemberOffsetRefs;
758760
759761 std::vector> Buffers;
760762 std::vector Members;
786788 Members.push_back(MemberRef);
787789 }
788790
791 unsigned MemberReferenceOffset = 0;
789792 if (Symtab) {
790 writeSymbolTable(Out, NewMembers, Members, MemberOffsetRefs);
793 MemberReferenceOffset =
794 writeSymbolTable(Out, NewMembers, Members, MemberOffsetRefs);
791795 }
792796
793797 std::vector StringMapIndexes;
794798 writeStringTable(Out, NewMembers, StringMapIndexes);
795
796 std::vector >::iterator MemberRefsI =
797 MemberOffsetRefs.begin();
798799
799800 unsigned MemberNum = 0;
800801 unsigned LongNameMemberNum = 0;
801802 unsigned NewMemberNum = 0;
803 std::vector MemberOffset;
802804 for (std::vector::iterator I = NewMembers.begin(),
803805 E = NewMembers.end();
804806 I != E; ++I, ++MemberNum) {
805807
806808 unsigned Pos = Out.tell();
807 while (MemberRefsI != MemberOffsetRefs.end() &&
808 MemberRefsI->second == MemberNum) {
809 Out.seek(MemberRefsI->first);
810 print32BE(Out, Pos);
811 ++MemberRefsI;
812 }
813 Out.seek(Pos);
809 MemberOffset.push_back(Pos);
814810
815811 MemoryBufferRef File = Members[MemberNum];
816812 if (I->isNewMember()) {
847843
848844 if (Out.tell() % 2)
849845 Out << '\n';
846 }
847
848 if (MemberReferenceOffset) {
849 Out.seek(MemberReferenceOffset);
850 for (unsigned MemberNum : MemberOffsetRefs)
851 print32BE(Out, MemberOffset[MemberNum]);
850852 }
851853
852854 Output.keep();