-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc: Update LLVM #26025
rustc: Update LLVM #26025
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
r? @brson cc @rust-lang/compiler - something to be aware of at least, and I may have updated something horribly incorrectly |
@eddyb notes on a comment from #23535 that we may want to restrict the |
Apparently, LLVM PR23763 is fixed now. |
@alexcrichton oh, of course, I forgot that. Maybe that machinery should be moved out of |
Looks like rust-lang/llvm@47dfcb7 did indeed fix the problems I was seeing! Updated the LLVM submodule. |
unwrap(PMB)->SLPVectorize = SLPVectorize; | ||
unwrap(PMB)->OptLevel = OptLevel; | ||
unwrap(PMB)->LoopVectorize = LoopVectorize; | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the PMB opt level is set here and not through llvm::LLVMPassManagerBuilderSetOptLevel
it appears that for LLVM < 7 we don't set the PMB opt level. Is that true, and is that bad?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh this reminded me that I meant to recompile these files against 3.5 and 3.6, and now having done so it looks like only MergeFunctions
wasn't available in 3.5 but everything else is now set on all versions.
r=me once you've answered my q's. This was a tough upgrade. Good work. |
This commit updates the LLVM submodule in use to the current HEAD of the LLVM repository. This is primarily being done to start picking up unwinding support for MSVC, which is currently unimplemented in the revision of LLVM we are using. Along the way a few changes had to be made: * As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some significant changes to our RustWrapper.cpp * As usual, some pass management changed in LLVM, so clang was re-scrutinized to ensure that we're doing the same thing as clang. * Some optimization options are now passed directly into the `PassManagerBuilder` instead of through CLI switches to LLVM. * The `NoFramePointerElim` option was removed from LLVM, favoring instead the `no-frame-pointer-elim` function attribute instead. * The `LoopVectorize` option of the LLVM optimization passes has been disabled as it causes a divide-by-zero exception to happen in LLVM for zero-sized types. This is reported as https://llvm.org/bugs/show_bug.cgi?id=23763 Additionally, LLVM has picked up some new optimizations which required fixing an existing soundness hole in the IR we generate. It appears that the current LLVM we use does not expose this hole. When an enum is moved, the previous slot in memory is overwritten with a bit pattern corresponding to "dropped". When the drop glue for this slot is run, however, the switch on the discriminant can often start executing the `unreachable` block of the switch due to the discriminant now being outside the normal range. This was patched over locally for now by having the `unreachable` block just change to a `ret void`.
💔 Test failed - auto-win-gnu-32-nopt-t |
@bors: r=brson 89cb355 |
⌛ Testing commit 89cb355 with merge 13e5306... |
💔 Test failed - auto-mac-64-nopt-t |
This is now blocked on https://llvm.org/bugs/show_bug.cgi?id=23779 |
☔ The latest upstream changes (presumably #25627) made this pull request unmergeable. Please resolve the merge conflicts. |
89cb355
to
c59700b
Compare
Ok, the LLVM bug has not been fixed yet, and I had some time to do some more investigation. The end result was adding this extra commit to the LLVM branch that we're using. Still running tests locally, but I suspect it will fix that segfault at least. re-r? @brson |
⌛ Testing commit 6583dda with merge 252855f... |
💔 Test failed - auto-mac-64-nopt-t |
Do you think you could fix this error before trying again?
|
6583dda
to
547418d
Compare
@bors: r=brson 547418d |
547418d
to
78ac14c
Compare
@bors: r=brson 78ac14c |
⌛ Testing commit 78ac14c with merge 87f60f5... |
💔 Test failed - auto-mac-32-opt |
This commit updates the LLVM submodule in use to the current HEAD of the LLVM repository. This is primarily being done to start picking up unwinding support for MSVC, which is currently unimplemented in the revision of LLVM we are using. Along the way a few changes had to be made: * As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some significant changes to our RustWrapper.cpp * As usual, some pass management changed in LLVM, so clang was re-scrutinized to ensure that we're doing the same thing as clang. * Some optimization options are now passed directly into the `PassManagerBuilder` instead of through CLI switches to LLVM. * The `NoFramePointerElim` option was removed from LLVM, favoring instead the `no-frame-pointer-elim` function attribute instead. Additionally, LLVM has picked up some new optimizations which required fixing an existing soundness hole in the IR we generate. It appears that the current LLVM we use does not expose this hole. When an enum is moved, the previous slot in memory is overwritten with a bit pattern corresponding to "dropped". When the drop glue for this slot is run, however, the switch on the discriminant can often start executing the `unreachable` block of the switch due to the discriminant now being outside the normal range. This was patched over locally for now by having the `unreachable` block just change to a `ret void`.
78ac14c
to
f9d4149
Compare
This commit updates the LLVM submodule in use to the current HEAD of the LLVM repository. This is primarily being done to start picking up unwinding support for MSVC, which is currently unimplemented in the revision of LLVM we are using. Along the way a few changes had to be made: * As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some significant changes to our RustWrapper.cpp * As usual, some pass management changed in LLVM, so clang was re-scrutinized to ensure that we're doing the same thing as clang. * Some optimization options are now passed directly into the `PassManagerBuilder` instead of through CLI switches to LLVM. * The `NoFramePointerElim` option was removed from LLVM, favoring instead the `no-frame-pointer-elim` function attribute instead. * The `LoopVectorize` option of the LLVM optimization passes has been disabled as it causes a divide-by-zero exception to happen in LLVM for zero-sized types. This is reported as https://llvm.org/bugs/show_bug.cgi?id=23763 Additionally, LLVM has picked up some new optimizations which required fixing an existing soundness hole in the IR we generate. It appears that the current LLVM we use does not expose this hole. When an enum is moved, the previous slot in memory is overwritten with a bit pattern corresponding to "dropped". When the drop glue for this slot is run, however, the switch on the discriminant can often start executing the `unreachable` block of the switch due to the discriminant now being outside the normal range. This was patched over locally for now by having the `unreachable` block just change to a `ret void`.
Congratulations! 👍 😄 |
This caused a regression related to LLVM passes. I fixed it in #31176 |
LLVM was upgraded to a new version in this commit: rust-lang@f9d4149 which was part of this pull request: rust-lang#26025 Consider the following two lines from that commit: rust-lang@f9d4149#diff-a3b24dbe2ea7c1981f9ac79f9745f40aL462 rust-lang@f9d4149#diff-a3b24dbe2ea7c1981f9ac79f9745f40aL469 The purpose of these lines is to register LLVM passes. Prior to the that commit, the passes being handled were assumed to be ModulePasses (a specific type of LLVM pass) since they were being added to a ModulePass manager. After that commit, both lines were refactored (presumably in an attempt to DRY out the code), but the ModulePasses were changed to be registered to a FunctionPass manager. This change resulted in ModulePasses being run, but a Function object was being passed as a parameter to the pass instead of a Module, which resulted in segmentation faults. In this commit, I changed relevant sections of the code to check the type of the passes being added and register them to the appropriate pass manager. Closes rust-lang#31067
Register LLVM passes with the correct LLVM pass manager. LLVM was upgraded to a new version in this commit: f9d4149 which was part of this pull request: #26025 Consider the following two lines from that commit: f9d4149#diff-a3b24dbe2ea7c1981f9ac79f9745f40aL462 f9d4149#diff-a3b24dbe2ea7c1981f9ac79f9745f40aL469 The purpose of these lines is to register LLVM passes. Prior to the that commit, the passes being handled were assumed to be ModulePasses (a specific type of LLVM pass) since they were being added to a ModulePass manager. After that commit, both lines were refactored (presumably in an attempt to DRY out the code), but the ModulePasses were changed to be registered to a FunctionPass manager. This change resulted in ModulePasses being run, but a Function object was being passed as a parameter to the pass instead of a Module, which resulted in segmentation faults. In this commit, I changed relevant sections of the code to check the type of the passes being added and register them to the appropriate pass manager. Closes #31067
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
significant changes to our RustWrapper.cpp
ensure that we're doing the same thing as clang.
PassManagerBuilder
instead of through CLI switches to LLVM.NoFramePointerElim
option was removed from LLVM, favoring instead theno-frame-pointer-elim
function attribute instead.LoopVectorize
option of the LLVM optimization passes has been disabledas it causes a divide-by-zero exception to happen in LLVM for zero-sized
types. This is reported as https://llvm.org/bugs/show_bug.cgi?id=23763
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the
unreachable
block of the switch due to thediscriminant now being outside the normal range. This was patched over locally
for now by having the
unreachable
block just change to aret void
.