-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Missed optimization: fn type calls returning never are not noreturn #64219
Comments
Here, it is suggested that we do: rust/src/librustc_codegen_ssa/mir/block.rs Lines 237 to 243 in 766b10a
Also see tests src/test/codegen/noreturn-uninhabited.rs and src/test/codegen/noreturnflag.rs .
|
Closing. Currently |
@sanxiyn where is it applied and could you point me to a test that checks this for fn type calls ? I haven't been able to find any tests, and for this rust code: extern "C" { static FOO: fn() -> !; }
pub unsafe fn foo() { FOO(); } we emit: @FOO = external global void ()*
define void @foo() unnamed_addr #0 {
start:
%0 = load void ()*, void ()** @FOO, align 8, !nonnull !0
call void %0() ;; no noreturn here
unreachable
} like @varkor says and not @FOO = external global void ()*
define void @foo() unnamed_addr #0 {
start:
%0 = load void ()*, void ()** @FOO, align 8, !nonnull !0
call void %0() #1
unreachable
}
attributes #1 = { noreturn } |
Where it is applied can be easily found by grepping |
Guess: it seems |
So how do you explain that the LLVM-IR generated by rustc that I just showed does not contain it ? |
@sanxiyn this issue is about function types, like |
Oh. |
@varkor that comment says that functions returning uninhabited types are marked noreturn, but we can't mark function pointers noreturn (they don't support LLVM attributes). We can add attributes to the call site of the function pointer, e.g., as shown above, but since we are emitting an |
…ieyouxu Add a Few Codegen Tests Closes rust-lang#86109 Closes rust-lang#64219 Those issues somehow got fixed over time. So, this PR adds a couple of codegen tests to ensure we don't regress in the future.
Rollup merge of rust-lang#132170 - veera-sivarajan:codegen-tests, r=jieyouxu Add a Few Codegen Tests Closes rust-lang#86109 Closes rust-lang#64219 Those issues somehow got fixed over time. So, this PR adds a couple of codegen tests to ensure we don't regress in the future.
We currently do not annotate calls to function types returning Never as
noreturn
, but we probably should. This is similar to #64090 .The text was updated successfully, but these errors were encountered: