This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Replace OutputSection* with uint16_t index in Chunk
ClosedPublic

Authored by rnk on May 23 2019, 5:01 PM.

Details

Summary

Shaves another 8 bytes off of SectionChunk, the most commonly allocated
type in LLD.

These indices are only valid after we've assigned chunks to output
sections and removed empty sections, so do that in a new pass.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

rnk created this revision.May 23 2019, 5:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2019, 5:01 PM
Herald added a subscriber: arphaman. · View Herald Transcript
ruiu accepted this revision.May 24 2019, 5:26 AM

LGTM

This revision is now accepted and ready to land.May 24 2019, 5:26 AM

Great stuff, thanks for doing this Reid! :) Inherently, this should make things a bit faster, it will also reduce cache misses.
We use a neat tool called Crunchersharp to have a broader overview:

aganea added inline comments.May 24 2019, 9:08 AM
lld/test/COFF/strtab-size.s
16 ↗(On Diff #201098)

Could you please explain why this changed? Just curious.

rnk marked an inline comment as done.May 24 2019, 11:07 AM

Great stuff, thanks for doing this Reid! :) Inherently, this should make things a bit faster, it will also reduce cache misses.

Yep, that's the hope. :) I really should go back to PDB memory usage optimization, though, it is the 80% of the 80/20 portion.

We use a neat tool called Crunchersharp to have a broader overview:

Thanks, I built it, but when I try to use it to load lld.pdb, it raises a "class not registered" exception, despite the fact that I followed the README.md instructions and registered msdia120.dll. DIA registration seems to be a continuing pain point in the Windows development world. :( I'll mess around with it.

lld/test/COFF/strtab-size.s
16 ↗(On Diff #201098)

When I dumped the symbols, .data and .bss no longer showed up. Now that we assign output sections to chunks after removing zero-size output sections, these symbols from the input objects no longer show up in the symbol table. llvm-mc always creates zero-size .data and .bss, although perhaps it shouldn't.

This revision was automatically updated to reflect the committed changes.

Thanks, I built it, but when I try to use it to load lld.pdb, it raises a "class not registered" exception, despite the fact that I followed the README.md instructions and registered msdia120.dll. DIA registration seems to be a continuing pain point in the Windows development world. :( I'll mess around with it.

I do this:

@echo off

@REM AUTO-ELEVATE the batch file to admin if needed!
net file 1>nul 2>nul && goto :run || powershell -ex unrestricted -Command "Start-Process -Wait -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c \"%~fnx0\" %*'"
goto :eof
:run

regsvr32.exe "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\DIA SDK\bin\msdia140.dll"
regsvr32.exe "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\DIA SDK\bin\amd64\msdia140.dll"
rnk added a comment.May 24 2019, 1:08 PM
regsvr32.exe "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\DIA SDK\bin\msdia140.dll"
regsvr32.exe "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\DIA SDK\bin\amd64\msdia140.dll"

I ran an elevated cmd prompt, and ran both the above regsvr32 commands, but I still get:

System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {3BFCEA48-620F-4B6B-81F7-B9AF75454C7D} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

The Interop.Dia2Lib.dll and the msdiaXXX.dll have to match. Try regsvr32.exe "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\msdia120.dll" (or look for msdia120.dll on your PC).