Skip to content

Organize SILOptimizer/Utils headers. Remove Local.h. #27417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2019
Merged

Organize SILOptimizer/Utils headers. Remove Local.h. #27417

merged 2 commits into from
Oct 2, 2019

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Sep 28, 2019

The XXOptUtils.h convention is already established and parallels
the SIL/XXUtils convention.

New:

  • InstOptUtils.h
  • CFGOptUtils.h
  • BasicBlockOptUtils.h
  • ValueLifetime.h

Removed:

  • Local.h
  • Two conflicting CFG.h files

This reorganization is helpful before I introduce more
utilities for block cloning similar to SinkAddressProjections.

Move the control flow utilies out of Local.h, which was an
unreadable, unprincipled mess. Rename it to InstOptUtils.h, and
confine it to small APIs for working with individual instructions.
These are the optimizer's additions to /SIL/InstUtils.h.

Rename CFG.h to CFGOptUtils.h and remove the one in /Analysis. Now
there is only SIL/CFG.h, resolving the naming conflict within the
swift project (this has always been a problem for source tools). Limit
this header to low-level APIs for working with branches and CFG edges.

Add BasicBlockOptUtils.h for block level transforms (it makes me sad
that I can't use BBOptUtils.h, but SIL already has
BasicBlockUtils.h). These are larger APIs for cloning or removing
whole blocks.

@atrick
Copy link
Contributor Author

atrick commented Sep 28, 2019

@swift-ci test

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with this in principle (splitting Local.h).

My one request before you merge is if you can fix up/modernize the files that are being completely moved? This is a nice time to perform such transformations.


/// Return true if there are any users of V outside the specified block.
inline bool isUsedOutsideOfBlock(SILValue V) {
auto *BB = V->getParentBlock();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an example of where the style is no beuano b/c of the age of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose I could make a pass over the code and convert variable names to lower camel. Are there any other specific conventions that you think need to be fixed? I don't want to rewrite anything in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with that and would like a git-clang-format as well. I would do it as a separate commit for cleanliness purposes. (I don't think it needs to be a separate PR, but you do you?).

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for cleaning this up!

@jrose-apple
Copy link
Contributor

My one request before you merge is if you can fix up/modernize the files that are being completely moved? This is a nice time to perform such transformations.

If you do do this, please make it a separate commit from the move. Otherwise it's a lot harder to track back the history of the file.

@gottesmm
Copy link
Contributor

@jrose-apple (noticing the -1). git's diff is good enough today to do renames of cases/ignore whitespace changes when doing a blame. That being said, I also think that doing this in a separate commit is ok from my perspective (and slightly cleaner).

@atrick
Copy link
Contributor Author

atrick commented Sep 30, 2019

@jrose-apple I strongly agree--moving code around should just move the code without other lexical changes. I'll try to add one extra commit for camelCase, and a second extra commit for clang-format. I took @gottesmm's suggestion to be purely from a social engineering standpoint: when you take to cleanup code, just clean it up all the way.

That said, I have an important bug fix blocked on this so might end up splitting PRs if it takes too long.

@atrick
Copy link
Contributor Author

atrick commented Oct 1, 2019

@gottesmm modernization is done now, at least to the extent I can spend time on it:
06104f5

@atrick
Copy link
Contributor Author

atrick commented Oct 1, 2019

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Oct 1, 2019

Build failed
Swift Test OS X Platform
Git Sha - cad03df036247a28396a16c0dd8b0d22c1a6d7b1

@swift-ci
Copy link
Contributor

swift-ci commented Oct 1, 2019

Build failed
Swift Test Linux Platform
Git Sha - 06104f5c84e2fc5c0dc17b623df9355f1725b608

@atrick
Copy link
Contributor Author

atrick commented Oct 2, 2019

@swift-ci test linux platform

@gottesmm
Copy link
Contributor

gottesmm commented Oct 2, 2019

SGTM

@atrick
Copy link
Contributor Author

atrick commented Oct 2, 2019

@swift-ci smoke test

atrick added 2 commits October 2, 2019 11:34
The XXOptUtils.h convention is already established and parallels
the SIL/XXUtils convention.

New:
- InstOptUtils.h
- CFGOptUtils.h
- BasicBlockOptUtils.h
- ValueLifetime.h

Removed:
- Local.h
- Two conflicting CFG.h files

This reorganization is helpful before I introduce more
utilities for block cloning similar to SinkAddressProjections.

Move the control flow utilies out of Local.h, which was an
unreadable, unprincipled mess. Rename it to InstOptUtils.h, and
confine it to small APIs for working with individual instructions.
These are the optimizer's additions to /SIL/InstUtils.h.

Rename CFG.h to CFGOptUtils.h and remove the one in /Analysis. Now
there is only SIL/CFG.h, resolving the naming conflict within the
swift project (this has always been a problem for source tools). Limit
this header to low-level APIs for working with branches and CFG edges.

Add BasicBlockOptUtils.h for block level transforms (it makes me sad
that I can't use BBOptUtils.h, but SIL already has
BasicBlockUtils.h). These are larger APIs for cloning or removing
whole blocks.
Requested by gottesmm during review.

Update the variable naming conventions to lower-camel.

Run clang-format.

I'm sure I missed some local variables somewhere--this was a best
effort.
@atrick
Copy link
Contributor Author

atrick commented Oct 2, 2019

@swift-ci smoke test and merge

1 similar comment
@atrick
Copy link
Contributor Author

atrick commented Oct 2, 2019

@swift-ci smoke test and merge

@swift-ci swift-ci merged commit 62ccf81 into swiftlang:master Oct 2, 2019
@atrick atrick deleted the cleanup-cfg-utils branch December 23, 2019 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants