This is an archive of the discontinued LLVM Phabricator instance.

MC: Don't align COFF section contents.
ClosedPublic

Authored by pcc on Aug 22 2018, 8:23 PM.

Details

Summary

Aligning section contents is not required, but only
recommended, by the specification. Microsoft's documentation says
(https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format#section-table-section-headers):
"For object files, the value should be aligned on a 4-byte boundary
for best performance."

However, according to my measurements, aligning section contents has
a neutral to negative effect on performance.

I measured the median run time of 100 links of Chromium's
base_unittests on Linux with lld-link and on Windows with link.exe with
both aligned and unaligned sections. On Linux I didn't see a measurable
performance difference, and on Windows the link was slightly faster
with unaligned sections (presumably because on Windows the bottleneck
is I/O).

Also, the sections created by cl.exe are unaligned, so we should expect
tools to broadly accept unaligned sections.

Diff Detail

Event Timeline

pcc created this revision.Aug 22 2018, 8:23 PM
This revision is now accepted and ready to land.Aug 22 2018, 10:10 PM
This revision was automatically updated to reflect the committed changes.