This is an archive of the discontinued LLVM Phabricator instance.

Simplify SORT and --sort-section command line option handling.
ClosedPublic

Authored by ruiu on Sep 16 2016, 2:18 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu updated this revision to Diff 71697.Sep 16 2016, 2:18 PM
ruiu updated this revision to Diff 71699.
ruiu retitled this revision from to Simplify SORT and --sort-section command line option handling..
ruiu updated this object.
ruiu added a reviewer: grimar.
ruiu added a subscriber: llvm-commits.
  • update comments
ruiu updated this revision to Diff 71700.Sep 16 2016, 2:24 PM

Rebased.

grimar edited edge metadata.Sep 17 2016, 1:35 AM

My comments below, every of them is just an IMHO of course.

ELF/LinkerScript.cpp
169 ↗(On Diff #71700)

So you can call sortSections() or not call it, and function itself can
do sort or not, while it's name contains "sort" explicitly.

I understand why you had to do all that, but it is much
more confusing than was for me.

189 ↗(On Diff #71700)

This comment says nothing about how rules are applied,
selectSortKind() had many of them, though I think it could leave fully without,
as SortSectionPolicy had very clear constant names.

I can't say the same for this code though.
I thought you wanted to have more comments generally,
if they helps to avoid reading code too much.
Do you find them excessive in your variant ?

1012 ↗(On Diff #71700)

By the way this place did not need the comment before renaming IgnoreConfig to None, I think code on the left side (if take version before renaming) is much more readable without need of in-mind-debugging.

rafael accepted this revision.Sep 19 2016, 10:11 AM
rafael added a reviewer: rafael.
rafael added a subscriber: rafael.

I do like this new one better, but I think it needs a few more comments.

In particular, mention that the command line replaces the inner sort if not set explicitly.

BTW, this and the previous code would crash if SORT_NONE was the inner sort, no?

ELF/LinkerScript.cpp
165 ↗(On Diff #71700)

static

This revision is now accepted and ready to land.Sep 19 2016, 10:11 AM
ruiu updated this revision to Diff 71884.Sep 19 2016, 3:22 PM
ruiu edited edge metadata.
  • Update comments
  • Fix a bug if a SORT_NONE is used as an inner sort directive.
ruiu added a comment.Sep 19 2016, 3:27 PM

George, I think this is better as it directly works on data structure we'd like to sort, rather than creating directives, fix it in the second pass, and then apply them. I updated the comment to describe how it works. Don't you still dislike this?

grimar accepted this revision.Sep 20 2016, 12:47 AM
grimar edited edge metadata.

It looks much better when there are comments like that near. Thanks !

This revision was automatically updated to reflect the committed changes.