This is an archive of the discontinued LLVM Phabricator instance.

lld-link: Store comdat selection in SectionChunk, reject more invalid associated comdats
ClosedPublic

Authored by thakis on Jan 18 2019, 1:27 PM.

Details

Summary

I need the comdat selection for PR40094. To keep the patch for that smaller, I'm adding it here, and as a first application I'm using it to reject associative comdats referring to earlier associative comdats. Depends on D56929; together with that all associative comdats referring to other associative comdats are now rejected.

Diff Detail

Repository
rL LLVM

Event Timeline

thakis created this revision.Jan 18 2019, 1:27 PM
pcc added inline comments.Jan 22 2019, 6:42 PM
lld/COFF/InputFiles.cpp
229 ↗(On Diff #183014)

For lambdas only used locally within a function we normally use an implicit capture with [&].

258 ↗(On Diff #183014)

Maybe move this inside readSection and do C->Selection = Def->Selection;?

lld/test/COFF/associative-comdat-order.s
1 ↗(On Diff #183014)

(Sorry didn't notice this on your other patch)

This isn't an assembly file, so the extension should be .test.

thakis updated this revision to Diff 183542.Jan 25 2019, 7:32 AM
thakis marked 2 inline comments as done.
thakis added inline comments.
lld/COFF/InputFiles.cpp
258 ↗(On Diff #183014)

That's a good suggestion, but Def->Selection is an uint8_t while C->Selection is a COMDATType.

I could make readSection() do validation and error out if Def->Selection is something unknown, but in the upcoming patch for better Selection handling I need to do this validation long before I call readSection(), so I'd have to do it in two places then. So I figured setting it here is maybe easier?

lld/test/COFF/associative-comdat-order.s
1 ↗(On Diff #183014)

Renamed in 352074.

ruiu accepted this revision.Jan 25 2019, 1:36 PM

LGTM

lld/COFF/InputFiles.cpp
229 ↗(On Diff #183542)

nit: since this function reads associative comdat sections, Assoc in a variable name seems redundant.

This revision is now accepted and ready to land.Jan 25 2019, 1:36 PM
thakis marked an inline comment as done.Jan 25 2019, 4:15 PM
This revision was automatically updated to reflect the committed changes.

It looks like this change broke the windows bot:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/1030

For some reason the change isn't logged as one of the ones included in the build, but it was fetched (http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/1030/steps/svn-lld/logs/stdio) and built.

It looks like this change broke the windows bot:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/1030

For some reason the change isn't logged as one of the ones included in the build, but it was fetched (http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/1030/steps/svn-lld/logs/stdio) and built.

Thanks for the note. r352304 will hopefully help.