<div dir="ltr">The existing test cases using llvm-readobj should suffice. Output from readobj didn't change, as the tool doesn't care whether or not the string it's printing is an alias of something.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 24, 2015 at 4:21 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">testcase? :-)<br>
<div class="HOEnZb"><div class="h5"><br>
On 24 March 2015 at 18:43, Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br>
> Author: ruiu<br>
> Date: Tue Mar 24 17:43:58 2015<br>
> New Revision: 233128<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=233128&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=233128&view=rev</a><br>
> Log:<br>
> PECOFF: Reduce import table size.<br>
><br>
> Import Lookup Table in Import Directory Table has the same contents<br>
> as Hint/Name Table. Symbol names imported from DLLs are pointed by<br>
> both Import Directory Table and Hint/Name Table. We had duplicate<br>
> strings there.<br>
><br>
> This patch eliminates that duplication to make the table smaller.<br>
> This should reduce binary size by the sum of lengths of imported<br>
> symbols.<br>
><br>
> Modified:<br>
> lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp<br>
><br>
> Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp?rev=233128&r1=233127&r2=233128&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp?rev=233128&r1=233127&r2=233128&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp (original)<br>
> +++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp Tue Mar 24 17:43:58 2015<br>
> @@ -69,6 +69,7 @@ static std::vector<ImportTableEntryAtom<br>
> createImportTableAtoms(IdataContext &context,<br>
> const std::vector<COFFSharedLibraryAtom *> &sharedAtoms,<br>
> bool shouldAddReference, StringRef sectionName,<br>
> + std::map<StringRef, HintNameAtom *> &hintNameCache,<br>
> llvm::BumpPtrAllocator &alloc) {<br>
> std::vector<ImportTableEntryAtom *> ret;<br>
> for (COFFSharedLibraryAtom *atom : sharedAtoms) {<br>
> @@ -81,9 +82,16 @@ createImportTableAtoms(IdataContext &con<br>
> } else {<br>
> // Import by name<br>
> entry = new (alloc) ImportTableEntryAtom(context, 0, sectionName);<br>
> - HintNameAtom *hintName =<br>
> - new (alloc) HintNameAtom(context, atom->hint(), atom->importName());<br>
> - addDir32NBReloc(entry, hintName, context.ctx.getMachineType(), 0);<br>
> + HintNameAtom *hintNameAtom;<br>
> + auto it = hintNameCache.find(atom->importName());<br>
> + if (it == hintNameCache.end()) {<br>
> + hintNameAtom = new (alloc) HintNameAtom(<br>
> + context, atom->hint(), atom->importName());<br>
> + hintNameCache[atom->importName()] = hintNameAtom;<br>
> + } else {<br>
> + hintNameAtom = it->second;<br>
> + }<br>
> + addDir32NBReloc(entry, hintNameAtom, context.ctx.getMachineType(), 0);<br>
> }<br>
> ret.push_back(entry);<br>
> if (shouldAddReference)<br>
> @@ -104,10 +112,13 @@ void ImportDirectoryAtom::addRelocations<br>
> // same. The PE/COFF loader overwrites the import address tables with the<br>
> // pointers to the referenced items after loading the executable into<br>
> // memory.<br>
> + std::map<StringRef, HintNameAtom *> hintNameCache;<br>
> std::vector<ImportTableEntryAtom *> importLookupTables =<br>
> - createImportTableAtoms(context, sharedAtoms, false, ".idata.t", _alloc);<br>
> + createImportTableAtoms(context, sharedAtoms, false, ".idata.t",<br>
> + hintNameCache, _alloc);<br>
> std::vector<ImportTableEntryAtom *> importAddressTables =<br>
> - createImportTableAtoms(context, sharedAtoms, true, ".idata.a", _alloc);<br>
> + createImportTableAtoms(context, sharedAtoms, true, ".idata.a",<br>
> + hintNameCache, _alloc);<br>
><br>
> addDir32NBReloc(this, importLookupTables[0], context.ctx.getMachineType(),<br>
> offsetof(ImportDirectoryTableEntry, ImportLookupTableRVA));<br>
> @@ -157,8 +168,10 @@ void DelayImportDirectoryAtom::addReloca<br>
> // as (non-delay) import table's Import Lookup Table. Contains<br>
> // imported function names. This is a parallel array of AddressTable<br>
> // field.<br>
> + std::map<StringRef, HintNameAtom *> hintNameCache;<br>
> std::vector<ImportTableEntryAtom *> nameTable =<br>
> - createImportTableAtoms(context, sharedAtoms, false, ".didat", _alloc);<br>
> + createImportTableAtoms(<br>
> + context, sharedAtoms, false, ".didat", hintNameCache, _alloc);<br>
> addDir32NBReloc(<br>
> this, nameTable[0], context.ctx.getMachineType(),<br>
> offsetof(delay_import_directory_table_entry, DelayImportNameTable));<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>