Uh oh!
There was an error while loading. Please reload this page.
Use call instead of invoke for functions that cannot unwind - #70467
Conversation
nikic
commented
Mar 27, 2020
There are some LLVM intrinsics that do support invokes, you can find the list at https://github.com/llvm/llvm-project/blob/30a8b77080b98ffdd1837d2ea2e74f91e40cc867/llvm/lib/IR/Verifier.cpp#L4164-L4175. Apart from maybe the wasm one, probably nothing that's relevant to Rust. As a side-note, LLVM intrinsics should always use the "unadjusted" ABI, something that is not happening right now. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I think this PR is branded as fixing a bug, but it's changing a lot about how @nikic I think those intrinsics (if ever used directly from a library, which we should've never allowed, but that's another discussion) should be marked explicitly with |
This comment has been minimized.
This comment has been minimized.
c0d2691 to
5461dffComparewesleywiser
commented
Mar 27, 2020
I agree. I wouldn't want to maintain a list of unwinding intrinsics in rustc and using |
bors
commented
Mar 30, 2020
☔ The latest upstream changes (presumably #70536) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
If this logic now lives in librustc, that might help with #65303.
…ddyb Add `can_unwind` field to `FnAbi` This is a pure refactoring with no behavior changes. Extracted out of rust-lang#70467 r? @eddyb
…ddyb Add `can_unwind` field to `FnAbi` This is a pure refactoring with no behavior changes. Extracted out of rust-lang#70467 r? @eddyb
5461dff to
098c46dCompareThe `FnAbi` now knows if the function is allowed to unwind. If a function isn't allowed to unwind, we can use a `call` instead of an `invoke`. This resolves an issue when calling LLVM intrinsics which cannot unwind LLVM will generate an error if you attempt to invoke them so we need to ignore cleanup blocks in codegen and generate a call instead.
098c46d to
8da26e0Comparecall instead of invoke for functions that cannot unwind wesleywiser
commented
Apr 15, 2020
I believe this is ready for review. |
eddyb
commented
Apr 16, 2020
r? @nagisa (LGTM, but I'm not sure if this is going to affect some ongoing ffi-unwind stuff) |
nagisa
left a comment
There was a problem hiding this comment.
r=me after at least an issue is filled about not generating cleanup blocks in the first place.
| if let Some(cleanup) = cleanup { | ||
| // If there is a cleanup block and the function we're calling can unwind, then | ||
| // do an invoke, otherwise do a call. | ||
| if let Some(cleanup) = cleanup.filter(|_| fn_abi.can_unwind) { |
There was a problem hiding this comment.
IMO in most instances this should happen way earlier. That is, the cleanup blocks should not be reach codegen in the first place for calls of functions that cannot unwind. This can happen either during MIR construction or afterwards in some clean-up pass.
This piece of code still needs to exist, of course, because fn_abi information in some cases may only be available after monomorphization, but the test case that changes in this PR does not involve generics...
I’m fine with work to do this happening in some follow-up PR (possibly implemented by somebody else), but in that case at least an issue needs to exist to that effect.
BatmanAoD
commented
Apr 16, 2020
Amanieu
commented
Apr 16, 2020
@BatmanAoD It doesn't matter since unwinding from |
wesleywiser
commented
Apr 17, 2020
@bors r=nagisa |
bors
commented
Apr 17, 2020
📌 Commit 8da26e0 has been approved by |
Use `call` instead of `invoke` for functions that cannot unwind The `FnAbi` now knows if the function is allowed to unwind. If a function isn't allowed to unwind, we can use a `call` instead of an `invoke`. This resolves an issue when calling LLVM intrinsics which cannot unwind LLVM will generate an error if you attempt to invoke them so we need to ignore cleanup blocks in codegen and generate a call instead. Fixesrust-lang#69911 r? @eddyb cc @rust-lang/wg-ffi-unwind
Rollup of 6 pull requests Successful merges: - rust-lang#70467 (Use `call` instead of `invoke` for functions that cannot unwind ) - rust-lang#71070 (rustbuild: Remove stage 0 LLD flavor workaround for MSVC) - rust-lang#71167 (big-O notation: parenthesis for function calls, explicit multiplication) - rust-lang#71238 (Miri: fix typo) - rust-lang#71242 (Format Mailmap To Work With GitHub) - rust-lang#71243 (Account for use of `try!()` in 2018 edition and guide users in the right direction) Failed merges: r? @ghost
The
FnAbinow knows if the function is allowed to unwind. If afunction isn't allowed to unwind, we can use a
callinstead of aninvoke.This resolves an issue when calling LLVM intrinsics which cannot unwind
LLVM will generate an error if you attempt to invoke them so we need to
ignore cleanup blocks in codegen and generate a call instead.
Fixes#69911
r? @eddyb
cc @rust-lang/wg-ffi-unwind