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

ICE: codegen: index out of bounds: the len is 3 but the index is 4 #124375

Closed
matthiaskrgr opened this issue Apr 25, 2024 · 0 comments · Fixed by #128004
Closed

ICE: codegen: index out of bounds: the len is 3 but the index is 4 #124375

matthiaskrgr opened this issue Apr 25, 2024 · 0 comments · Fixed by #128004
Labels
A-codegen Area: Code generation A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;

#[naked]
pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
    asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
}

original:

// compile-flags: -C no-prepopulate-passes
// needs-asm-support
// only-x86_64

#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;

// CHECK: Function Attrs: naked
// CHECK-NEXT: define{{.*}}void @naked_empty()
#[no_mangle]
#[naked]
pub unsafe extern "C" fn asm() {
    // CHECK-NEXT: {{.+}}:
    // CHECK-NEXT: call void asm
    // CHECK-NEXT: unreachable
    asm!("ret",
         options(noreturn));
}

// CHECK: Function Attrs: naked
// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %a, i64 %b)
#[no_mangle]
#[naked]
pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
    // CHECK-NEXT: {{.+}}:
    // CHECK-NEXT: call void asm
    // CHECK-NEXT: unreachable
    asm!("lea rax, [rdi + rsi]",
         "ret",
         options(noreturn));
}

Version information

rustc 1.79.0-nightly (cb3752d20 2024-04-25)
binary: rustc
commit-hash: cb3752d20e0f5d24348062211102a08d46fbecff
commit-date: 2024-04-25
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.4

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=0

Program output

warning: unused attribute
 --> /tmp/icemaker_global_tempdir.eKkYCL3DP8Cd/rustc_testrunner_tmpdir_reporting.YGEGx2f1RK8i/mvce.rs:6:1
  |
6 | #[naked]
  | ^^^^^^^^ help: remove this attribute
  |
note: attribute also specified here
 --> /tmp/icemaker_global_tempdir.eKkYCL3DP8Cd/rustc_testrunner_tmpdir_reporting.YGEGx2f1RK8i/mvce.rs:5:1
  |
5 | #[naked]
  | ^^^^^^^^
  = note: `#[warn(unused_attributes)]` on by default

WARN rustc_codegen_ssa::mir::locals Unexpected initial operand type: expected isize, found !.See <https://github.com/rust-lang/rust/issues/114858>.
WARN rustc_codegen_ssa::mir::locals Unexpected initial operand type: expected isize, found !.See <https://github.com/rust-lang/rust/issues/114858>.
thread 'rustc' panicked at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/compiler/rustc_codegen_ssa/src/mir/statement.rs:54:63:
index out of bounds: the len is 3 but the index is 4
stack backtrace:
   0:     0x7b37f3f16145 - std::backtrace_rs::backtrace::libunwind::trace::h5605728a39057d84
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7b37f3f16145 - std::backtrace_rs::backtrace::trace_unsynchronized::h26b02d645a74e0ae
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7b37f3f16145 - std::sys_common::backtrace::_print_fmt::h068d097fdd201426
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7b37f3f16145 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdbb63c7c16d10ece
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7b37f3f6521b - core::fmt::rt::Argument::fmt::h67dd1b13c2f2f60d
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/core/src/fmt/rt.rs:165:63
   5:     0x7b37f3f6521b - core::fmt::write::h7132c149ac34da54
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/core/src/fmt/mod.rs:1157:21
   6:     0x7b37f3f0accf - std::io::Write::write_fmt::h323f8c8c2c83029d
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/io/mod.rs:1832:15
   7:     0x7b37f3f15f1e - std::sys_common::backtrace::_print::hbbc04e79982f59bb
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7b37f3f15f1e - std::sys_common::backtrace::print::h30e4ba3a749f53ca
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7b37f3f18889 - std::panicking::default_hook::{{closure}}::h8a178c9d6b0b94e7
  10:     0x7b37f3f185cd - std::panicking::default_hook::hdd8156d952193739
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/panicking.rs:298:9
  11:     0x7b37f084e3dc - std[8bf3ba7b94ed234c]::panicking::update_hook::<alloc[a86d15d3d60259f5]::boxed::Box<rustc_driver_impl[ff0ca504bb3c8cda]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7b37f3f18f86 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha3edf74e61015c1d
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/alloc/src/boxed.rs:2036:9
  13:     0x7b37f3f18f86 - std::panicking::rust_panic_with_hook::hb81630742c93e4ac
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/panicking.rs:799:13
  14:     0x7b37f3f18d34 - std::panicking::begin_panic_handler::{{closure}}::hae457da9026d20e4
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/panicking.rs:664:13
  15:     0x7b37f3f16609 - std::sys_common::backtrace::__rust_end_short_backtrace::h21495a629a302214
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7b37f3f18a67 - rust_begin_unwind
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/panicking.rs:652:5
  17:     0x7b37f3f616e3 - core::panicking::panic_fmt::h935fb4d00ba2a2fa
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/core/src/panicking.rs:72:14
  18:     0x7b37f3f61907 - core::panicking::panic_bounds_check::h52ccb5f2347221e6
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/core/src/panicking.rs:275:5
  19:     0x7b37f288f5b5 - rustc_codegen_ssa[1b654a979dd64848]::mir::codegen_mir::<rustc_codegen_llvm[6449e36ab917380]::builder::Builder>
  20:     0x7b37f28759d0 - rustc_codegen_llvm[6449e36ab917380]::base::compile_codegen_unit::module_codegen
  21:     0x7b37f2871c96 - <rustc_codegen_llvm[6449e36ab917380]::LlvmCodegenBackend as rustc_codegen_ssa[1b654a979dd64848]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  22:     0x7b37f29fd9a9 - rustc_codegen_ssa[1b654a979dd64848]::base::codegen_crate::<rustc_codegen_llvm[6449e36ab917380]::LlvmCodegenBackend>
  23:     0x7b37f2ab3a0c - <rustc_codegen_llvm[6449e36ab917380]::LlvmCodegenBackend as rustc_codegen_ssa[1b654a979dd64848]::traits::backend::CodegenBackend>::codegen_crate
  24:     0x7b37f2ab339f - rustc_interface[79bb94ccf3e33350]::passes::start_codegen
  25:     0x7b37f2ab2a1a - <rustc_interface[79bb94ccf3e33350]::queries::Queries>::codegen_and_build_linker
  26:     0x7b37f27dd736 - rustc_interface[79bb94ccf3e33350]::interface::run_compiler::<core[69fef399d12a0664]::result::Result<(), rustc_span[fd9590449ede6f6]::ErrorGuaranteed>, rustc_driver_impl[ff0ca504bb3c8cda]::run_compiler::{closure#0}>::{closure#1}
  27:     0x7b37f27c7727 - std[8bf3ba7b94ed234c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[79bb94ccf3e33350]::util::run_in_thread_with_globals<rustc_interface[79bb94ccf3e33350]::util::run_in_thread_pool_with_globals<rustc_interface[79bb94ccf3e33350]::interface::run_compiler<core[69fef399d12a0664]::result::Result<(), rustc_span[fd9590449ede6f6]::ErrorGuaranteed>, rustc_driver_impl[ff0ca504bb3c8cda]::run_compiler::{closure#0}>::{closure#1}, core[69fef399d12a0664]::result::Result<(), rustc_span[fd9590449ede6f6]::ErrorGuaranteed>>::{closure#0}, core[69fef399d12a0664]::result::Result<(), rustc_span[fd9590449ede6f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[69fef399d12a0664]::result::Result<(), rustc_span[fd9590449ede6f6]::ErrorGuaranteed>>
  28:     0x7b37f27c74ea - <<std[8bf3ba7b94ed234c]::thread::Builder>::spawn_unchecked_<rustc_interface[79bb94ccf3e33350]::util::run_in_thread_with_globals<rustc_interface[79bb94ccf3e33350]::util::run_in_thread_pool_with_globals<rustc_interface[79bb94ccf3e33350]::interface::run_compiler<core[69fef399d12a0664]::result::Result<(), rustc_span[fd9590449ede6f6]::ErrorGuaranteed>, rustc_driver_impl[ff0ca504bb3c8cda]::run_compiler::{closure#0}>::{closure#1}, core[69fef399d12a0664]::result::Result<(), rustc_span[fd9590449ede6f6]::ErrorGuaranteed>>::{closure#0}, core[69fef399d12a0664]::result::Result<(), rustc_span[fd9590449ede6f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[69fef399d12a0664]::result::Result<(), rustc_span[fd9590449ede6f6]::ErrorGuaranteed>>::{closure#2} as core[69fef399d12a0664]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:     0x7b37f3f22e1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5acff674129337c4
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/alloc/src/boxed.rs:2022:9
  30:     0x7b37f3f22e1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8aabd62c8ccb0918
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/alloc/src/boxed.rs:2022:9
  31:     0x7b37f3f22e1b - std::sys::pal::unix::thread::Thread::new::thread_start::h65e97bc238441a51
                               at /rustc/cb3752d20e0f5d24348062211102a08d46fbecff/library/std/src/sys/pal/unix/thread.rs:108:17
  32:     0x7b37f3cc155a - <unknown>
  33:     0x7b37f3d3ea3c - <unknown>
  34:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.79.0-nightly (cb3752d20 2024-04-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=0 -Z dump-mir-dir=dir

query stack during panic:
end of query stack
warning: 1 warning emitted


@rustbot label +F-naked_functions

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Apr 25, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 25, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 27, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 8, 2024
@fmease fmease added F-naked_functions `#![feature(naked_functions)]` A-inline-assembly Area: Inline assembly (`asm!(…)`) A-codegen Area: Code generation labels Jun 5, 2024
folkertdev added a commit to folkertdev/rust that referenced this issue Jul 20, 2024
folkertdev added a commit to folkertdev/rust that referenced this issue Jul 26, 2024
folkertdev added a commit to folkertdev/rust that referenced this issue Jul 27, 2024
folkertdev added a commit to folkertdev/rust that referenced this issue Jul 28, 2024
folkertdev added a commit to folkertdev/rust that referenced this issue Jul 31, 2024
correctly emit `.hidden`

this test was added in rust-lang#105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix rust-lang#124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
folkertdev added a commit to folkertdev/rust that referenced this issue Aug 7, 2024
correctly emit `.hidden`

this test was added in rust-lang#105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix rust-lang#124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
folkertdev added a commit to folkertdev/rust that referenced this issue Aug 11, 2024
correctly emit `.hidden`

this test was added in rust-lang#105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix rust-lang#124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
folkertdev added a commit to folkertdev/rust that referenced this issue Aug 11, 2024
correctly emit `.hidden`

this test was added in rust-lang#105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix rust-lang#124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
folkertdev added a commit to folkertdev/rust that referenced this issue Sep 5, 2024
correctly emit `.hidden`

this test was added in rust-lang#105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix rust-lang#124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
folkertdev added a commit to folkertdev/rust that referenced this issue Sep 27, 2024
correctly emit `.hidden`

this test was added in rust-lang#105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix rust-lang#124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
folkertdev added a commit to folkertdev/rust that referenced this issue Oct 7, 2024
correctly emit `.hidden`

this test was added in rust-lang#105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix rust-lang#124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue Dec 1, 2024
correctly emit `.hidden`

this test was added in rust-lang#105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix rust-lang#124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 1, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`
fmease added a commit to fmease/rust that referenced this issue Dec 4, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`
fmease added a commit to fmease/rust that referenced this issue Dec 5, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with ``@Amanieu`` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? ``@Amanieu``
folkertdev added a commit to folkertdev/rust that referenced this issue Dec 5, 2024
correctly emit `.hidden`

this test was added in rust-lang#105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix rust-lang#124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 8, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 8, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`

try-job: x86_64-gnu-nopt
jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 9, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`

try-job: x86_64-gnu-nopt
jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 9, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with ``@Amanieu`` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? ``@Amanieu``

try-job: x86_64-gnu-nopt
fmease added a commit to fmease/rust that referenced this issue Dec 9, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`

try-job: x86_64-gnu-nopt
try-job: x86_64-apple-1
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 9, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`

try-job: x86_64-gnu-nopt
try-job: x86_64-apple-1
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 10, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`

try-job: x86_64-gnu-nopt
try-job: x86_64-apple-1
try-job: x86-64-msvc
try-job: i686-mingw
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 10, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`

try-job: x86_64-gnu-nopt
try-job: x86_64-apple-1
try-job: x86_64-msvc
try-job: i686-mingw
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 10, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`

try-job: x86_64-gnu-nopt
try-job: x86_64-apple-1
try-job: x86_64-msvc
try-job: i686-mingw
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 11, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 11, 2024
codegen `#[naked]` functions using global asm

tracking issue: rust-lang#90957

Fixes rust-lang#124375

This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc).

I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about.

Combined with rust-lang#127853, if both accepted, I think that resolves all steps from the tracking issue.

r? `@Amanieu`
@bors bors closed this as completed in 1daec06 Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants