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. #51061

Closed
wants to merge 1 commit into from
Closed

Conversation

DiamondLovesYou
Copy link
Contributor

Use can be triggered via -Z polly, when rustc uses an LLVM which includes polly.

Force LLVM rebuild on buildbots.

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive
Copy link
Collaborator

warning Warning warning

  • These commits modify submodules.

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

r? @kennytm @ollie27

@rust-highfive rust-highfive assigned kennytm and unassigned estebank May 25, 2018
@kennytm
Copy link
Member

kennytm commented May 25, 2018

Previous discussion: #50044.

@kennytm
Copy link
Member

kennytm commented May 27, 2018

@bors r+

@bors
Copy link
Contributor

bors commented May 27, 2018

📌 Commit 27586fd has been approved by kennytm

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 27, 2018
@kennytm
Copy link
Member

kennytm commented May 27, 2018

cc #39884

@bors
Copy link
Contributor

bors commented May 27, 2018

⌛ Testing commit 27586fd2d4e1db8e30caf7423406ca18c50b14e5 with merge 15d620c54f78dcc994cb706abf7be4b2b0c8ba03...

@bors
Copy link
Contributor

bors commented May 27, 2018

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 27, 2018
@kennytm
Copy link
Member

kennytm commented May 27, 2018

It caused a bunch on undefined references when linking lib/LLVMPolly.dll (dll?) on Windows (i686-mingw-1).

[00:12:16] [2027/2254] Linking CXX shared module lib\LLVMPolly.dll
[00:12:16] FAILED: lib/LLVMPolly.dll 
[00:12:16] cmd.exe /C "cd . && C:\projects\rust\sccache.exe g++.exe  -ffunction-sections -fdata-sections -m32 -fno-omit-frame-pointer -Werror=date-time -std=gnu++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -fno-common -Woverloaded-virtual -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -fno-exceptions -fno-rtti  -O2   -shared -o lib\LLVMPolly.dll -Wl,--major-image-version,0,--minor-image-version,0 tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/DependenceInfo.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/PolyhedralInfo.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/ScopDetection.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/ScopDetectionDiagnostic.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/ScopInfo.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/ScopBuilder.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/ScopGraphPrinter.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/ScopPass.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/PruneUnprofitable.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/BlockGenerators.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/IslAst.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/IslExprBuilder.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/IslNodeBuilder.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/CodeGeneration.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/LoopGenerators.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/IRBuilder.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/Utils.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/RuntimeDebugBuilder.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/CodegenCleanup.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/CodeGen/PerfMonitor.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Exchange/JSONExporter.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Support/GICHelper.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Support/SCEVAffinator.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Support/SCEVValidator.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Support/RegisterPasses.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Support/ScopHelper.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Support/ScopLocation.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Support/ISLTools.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Support/DumpModulePass.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Support/VirtualInstruction.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/External/JSON/json_reader.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/External/JSON/json_value.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/External/JSON/json_writer.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/Canonicalization.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/CodePreparation.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/DeadCodeElimination.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/ScheduleOptimizer.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/FlattenSchedule.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/FlattenAlgo.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/ForwardOpTree.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/DeLICM.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/ZoneAlgo.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/Simplify.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/MaximalStaticExpansion.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/RewriteByReferenceParameters.cpp.obj tools/polly/lib/CMakeFiles/PollyCore.dir/Transform/ScopInliner.cpp.obj tools/polly/lib/CMakeFiles/LLVMPolly.dir/Polly.cpp.obj  lib/libPollyISL.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
[00:12:16] tools/polly/lib/CMakeFiles/PollyCore.dir/Analysis/DependenceInfo.cpp.obj:DependenceInfo.cpp:(.text$__tcf_2+0x11): undefined reference to `vtable for llvm::cl::Option'
...
[00:12:16] tools/polly/lib/CMakeFiles/LLVMPolly.dir/Polly.cpp.obj:Polly.cpp:(.text.startup._GLOBAL__sub_I_Polly.cpp+0x7): undefined reference to `llvm::PassRegistry::getPassRegistry()'
[00:12:16] collect2.exe: error: ld returned 1 exit status

@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 27, 2018
@DiamondLovesYou
Copy link
Contributor Author

Huh, that's odd. Rust shouldn't ever try to link polly dynamically, due to the fact that it's in LLVM*.* form and not libLLVM*.* form. So we could, as a last resort, just not build Polly when the host is Windows. I don't develop on windows normally (or at all really); let me setup my gaming windows VM to try and reproduce this. It would be unfortunate to have to disable this for Windows devs.

@bors
Copy link
Contributor

bors commented May 30, 2018

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

@pietroalbini pietroalbini added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 4, 2018
@DiamondLovesYou
Copy link
Contributor Author

Patch to make Polly not try to build the loadable modules on all Windows platforms: https://reviews.llvm.org/D51904.

@mati865 I made a minor change: I used LLVM_ENABLE_PLUGINS instead of checking platform specific booleans.

@kennytm kennytm added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 11, 2018
@mati865
Copy link
Contributor

mati865 commented Sep 11, 2018

@DiamondLovesYou MSYS2 builds LLVM with LLVM_BUILD_LLVM_DYLIB so it has LLVM_ENABLE_PLUGINS enabled and Polly doesn't build.

As long as Rust doesn't enable BUILD_SHARED_LIBS or LLVM_BUILD_LLVM_DYLIB for LLVM Polly should build on Windows.

@DiamondLovesYou
Copy link
Contributor Author

@mati865 Okay, I dug in and managed to (just now) fix the original issue. I built LLVM with LLVM_BUILD_LLVM_DYLIB && LLVM_LINK_LLVM_DYLIB on Msys/mingw/whatnot without disabling LLVMPolly!

Sadly, using LINK_POLLY_INTO_TOOLS and LLVM_LINK_LLVM_DYLIB together breaks some tools as Polly is linked into the dylib already.

@mati865
Copy link
Contributor

mati865 commented Sep 12, 2018

@DiamondLovesYou nice work but maybe you are going too deep? This is pretty much uncharted territory.
Ofc having it fully working everwhere would be nice but it's a lot of effort and time.
This PR seems to be already on pair with LLVM with Polly working on UNIX like platforms and not regress on Windows.

@DiamondLovesYou
Copy link
Contributor Author

@mati865 Maybe, but it doesn't matter now.

New patch: https://reviews.llvm.org/D51963.

@bors
Copy link
Contributor

bors commented Sep 12, 2018

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

@DiamondLovesYou
Copy link
Contributor Author

@mati865 https://reviews.llvm.org/D51984 and https://reviews.llvm.org/D51986

@lovesegfault
Copy link
Contributor

@DiamondLovesYou You're an absolute hero for pushing this through, thank you so much! Hope to see those Polly patches landing soon.

@DiamondLovesYou
Copy link
Contributor Author

Thanks! Hopefully I can actually get it in; a lot of platform specific issues are coming up, which are breaking check-all in different ways for the BUILD_SHARED_LIBS && LLVM_LINK_LLVM_DYLIB && platform combinations.

…uses an LLVM which includes polly.

Force LLVM rebuild on buildbots.
[submodule "src/polly"]
path = src/polly
url = 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.

Perhaps rust-lang should have its own fork of this repo?
I could imagine that if upstream polly gets synced with upstream llvm but rustc uses rust-lang-llvm with llvm upstream polly, there might be conflicts between let's say polly 8.0 and llvm 7.0 (the rustc-lang fork).

Copy link
Member

Choose a reason for hiding this comment

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

We could track the release_70 branch instead of master if version incompatibility is the only concern.

@bors
Copy link
Contributor

bors commented Oct 21, 2018

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

@Centril
Copy link
Contributor

Centril commented Dec 1, 2018

Ping from triage, @kennytm: should this PR be closed? @DiamondLovesYou any updates?

@Centril Centril added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Dec 1, 2018
@kennytm
Copy link
Member

kennytm commented Dec 1, 2018

@Centril this was blocked by several patched on LLVM. If OP did not have any updates this could be closed as S-blocked-closed.

@Centril Centril added S-blocked-closed and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Dec 1, 2018
@Centril
Copy link
Contributor

Centril commented Dec 1, 2018

Alright; closing as S-blocked-closed for the time being then.

@Centril Centril closed this Dec 1, 2018
@namibj namibj mentioned this pull request Aug 17, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Nov 9, 2020
Enable LLVM Polly via llvm-args.

I think doing it this way is better than in rust-lang#51061. Polly has other useful options and we probably don't want to create a `-Z` flag for each one of them.

![results](https://user-images.githubusercontent.com/7283601/97695555-338f7180-1adf-11eb-82bd-5130e0e6fa89.png)

[Benchmark](https://gist.github.com/JRF63/9a6268b91720958e90dbe7abffe20298)

I noticed that `-lto` seems to interfere with polly in this specific microbenchmark, as enabling it causes the perf to drop to that of non-polly builds.

Other related PRs: rust-lang#75615
@jyn514 jyn514 added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-blocked-closed labels Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.