Skip to content
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

Add Polly support #50044

Closed
wants to merge 1 commit into from
Closed

Conversation

DiamondLovesYou
Copy link
Contributor

@DiamondLovesYou DiamondLovesYou commented Apr 18, 2018

It is always compiled and linked, but not used by default.

Use can be triggered via -Z polly=true or at compiler build-time (see config.toml.example).

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@@ -1074,6 +1074,9 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
[TRACKED], "panic strategy to compile crate with"),
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
"enable incremental compilation"),
polly: bool = (option_env!("RUSTC_FORCE_USE_POLLY").map(|_| true ).unwrap_or(false),
Copy link
Member

Choose a reason for hiding this comment

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

Could you make this flag -Z polly instead of -C polly? We'll likely not insta-stabilize this flag.

BTW, x.map(|_| true).unwrap_or(false) is equivalent to x.is_some().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a codegen option though, to me it doesn't make sense to put it in with debugging options. I've moved it anyway, but yeah.

Second point is a good one, not sure what I was thinking on that.

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 18, 2018
@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 19, 2018

This would close #39884 :)

So thanks!

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 19, 2018
@kennytm
Copy link
Member

kennytm commented Apr 19, 2018

Assuming the error in #50044 (comment) does not affect LLVM 6, I'd like to check if polly fixes #45222.

@bors try

@bors
Copy link
Contributor

bors commented Apr 19, 2018

⌛ Trying commit 7762503 with merge af6e74d...

bors added a commit that referenced this pull request Apr 19, 2018
Add Polly support

It is always compiled and linked, but not used by default.

Use can be triggered via `-C polly=true` or at compiler build-time (see `config.toml.example`).
@bors
Copy link
Contributor

bors commented Apr 19, 2018

💔 Test failed - status-travis

@rust-highfive

This comment has been minimized.

1 similar comment
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@@ -1304,6 +1304,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"tell the linker to strip debuginfo when building without debuginfo enabled."),
share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
"make the current crate share its generic instantiations"),
polly: bool = (option_env!("RUSTC_FORCE_USE_POLLY").is_some(),
Copy link
Member

@kennytm kennytm Apr 19, 2018

Choose a reason for hiding this comment

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

I'd like a clarification of use of option_env!() here.

option_env!() is evaluated at compile time. This means if we set use-polly-by-default = true in config.toml, the produced rustc will always use Polly. Is this the intended behavior?

$ echo 'use-polly-by-default = true' >> config.toml
$ ./x.py build
...
$ rustc +stage2 x.rs
##^ will compile x.rs with -Zpolly even without RUSTC_FORCE_USE_POLLY=1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

Copy link
Member

Choose a reason for hiding this comment

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

@DiamondLovesYou Could you put the explanation into config.toml.example and also above this line in src/librustc/session/config.rs? Thanks.

(Also, the code still fails to link.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Re linking issue, yep. I failed to consider using the system LLVM, and am working on it (not super trivial, rustllvm can't initialize polly's passes, for example).

I suppose I should mention that the reason use-polly-by-default exists is so that one can run all the tests with polly enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if there is a better way...

Copy link
Member

Choose a reason for hiding this comment

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

@DiamondLovesYou You could also modify the bootstrap rustc (src/bootstrap/bin/rustc.rs) to always pass -Z polly when RUSTC_FORCE_USE_POLLY is set.

@kennytm kennytm added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 19, 2018
@bors
Copy link
Contributor

bors commented Apr 24, 2018

☔ The latest upstream changes (presumably #49837) made this pull request unmergeable. Please resolve the merge conflicts.

@kennytm
Copy link
Member

kennytm commented May 1, 2018

@bors try

@bors
Copy link
Contributor

bors commented May 1, 2018

⌛ Trying commit 337b28c with merge 16cc121...

bors added a commit that referenced this pull request May 1, 2018
Add Polly support

It is always compiled and linked, but not used by default.

Use can be triggered via `-Z polly=true` or at compiler build-time (see `config.toml.example`).
@bors
Copy link
Contributor

bors commented May 1, 2018

☀️ Test successful - status-travis
State: approved= try=True

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 1, 2018
@DiamondLovesYou
Copy link
Contributor Author

I've made a few changes. The use of polly is now not tied to the compiler's build time configuration.

}

pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command) {
pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command, is_test: bool) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of modifying rustc_cargo_env, which forces one to pass a magic boolean everywhere, I suggest you modify the Builder::cargo function (in builder.rs) such that rust_polly_tests is used when cmd is "test" or "bench".

Also, why the rust_polly_tests is used (is_test == true) for "check" and "doc" in the current implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of modifying rustc_cargo_env, which forces one to pass a magic boolean everywhere, I suggest you modify the Builder::cargo function (in builder.rs) such that rust_polly_tests is used when cmd is "test" or "bench".

Ok, that sounds better.

Also, why the rust_polly_tests is used (is_test == true) for "check" and "doc" in the current implementation?

I want to make sure all tests are run with the polly optimization, to guard against possible polly bugs.

Copy link
Member

Choose a reason for hiding this comment

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

I want to make sure all tests are run with the polly optimization, to guard against possible polly bugs.

No tests would be run with cargo check and cargo doc though. Maybe "test" isn't a good name for this configuration 🤔.


// We can't specify the full libname to rust, so the linker will always expect (on unix)
// LLVMPolly to be libLLVMPolly, which won't be present. I didn't realize this fact until
// after I won't the following, but maybe this issue will be resolved in the future.
Copy link
Member

Choose a reason for hiding this comment

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

I think there's some typo in this comment? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, you right.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

…uses an LLVM which includes polly.

Force LLVM rebuild on buildbots.
@DiamondLovesYou
Copy link
Contributor Author

I've removed and cleaned up usage of that is_test variable. Should be ready to go.

@@ -553,6 +553,18 @@ pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command) {
if builder.config.rustc_parallel_queries {
cargo.env("RUSTC_PARALLEL_QUERIES", "1");
}

let use_polly = match builder.kind {
Copy link
Member

Choose a reason for hiding this comment

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

builder.kind only records how x.py is invoked, i.e. if you use

./x.py test src/test/compile-fail ...

then librustc etc will be built with builder.config.rust_polly_tests instead of builder.config.rust_polly_self, even if it is a build artifact.

@@ -690,6 +690,10 @@ def update_submodules(self):
recorded_submodules[data[3]] = data[2]
for module in filtered_submodules:
self.update_submodule(module[0], module[1], recorded_submodules)
polly_path = "src/llvm/tools/polly"
if not os.path.exists(os.path.join(self.rust_root, polly_path)):
run(["git", "clone", "https://github.com/llvm-mirror/polly.git",
Copy link
Member

Choose a reason for hiding this comment

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

Can this not be a normal submodule placed in src/polly for example? I believe you can use LLVM_EXTERNAL_POLLY_SOURCE_DIR to tell llvm where to find it.

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 3, 2018
@bors
Copy link
Contributor

bors commented May 5, 2018

☔ The latest upstream changes (presumably #50276) made this pull request unmergeable. Please resolve the merge conflicts.

@pietroalbini
Copy link
Member

Ping from triage @DiamondLovesYou! There are some comments you should address.

@pietroalbini
Copy link
Member

Thank you for this PR @DiamondLovesYou! Unfortunately we haven't heard from you on this in a while, so I'm closing the PR to keep things tidy. Don't worry though, if you'll have time again in the future please reopen this PR, we'll be happy to review it again!

@gnzlbg
Copy link
Contributor

gnzlbg commented May 21, 2018 via email

@kennytm
Copy link
Member

kennytm commented May 21, 2018

@gnzlbg #50044 (review) and #50044 (review) and rebase on top of latest master.

@DiamondLovesYou
Copy link
Contributor Author

Sorry, I was AFK for a while. How does one reopen a PR?

@kennytm
Copy link
Member

kennytm commented May 25, 2018

@DiamondLovesYou You'll need to open a new PR since you've force-pushed the polly branch.

@kennytm kennytm mentioned this pull request May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants