Auto merge of #97512 - scottmcm:add-coldcc, r=nagisa,lcnr

Add support for emitting functions with `coldcc` to LLVM

The eventual goal is to try using this for things like the internal panicking stuff, to see whether it helps.
This commit is contained in:
bors 2022-06-07 08:12:45 +00:00
commit 91cacb3faf
14 changed files with 132 additions and 4 deletions

View file

@ -0,0 +1,18 @@
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]
#![feature(rust_cold_cc)]
// wasm marks the definition as `dso_local`, so allow that as optional.
// CHECK: define{{( dso_local)?}} coldcc void @this_should_never_happen(i16
// CHECK: call coldcc void @this_should_never_happen(i16
#[no_mangle]
pub extern "rust-cold" fn this_should_never_happen(x: u16) {}
pub fn do_things(x: u16) {
if x == 12345 {
this_should_never_happen(54321);
}
}

View file

@ -4,7 +4,7 @@ error[E0703]: invalid ABI: found `路濫狼á́́`
LL | extern "路濫狼á́́" fn foo() {}
| ^^^^^^^^^ invalid ABI
|
= help: valid ABIs: Rust, C, C-unwind, cdecl, cdecl-unwind, stdcall, stdcall-unwind, fastcall, fastcall-unwind, vectorcall, vectorcall-unwind, thiscall, thiscall-unwind, aapcs, aapcs-unwind, win64, win64-unwind, sysv64, sysv64-unwind, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, wasm, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted
= help: valid ABIs: Rust, C, C-unwind, cdecl, cdecl-unwind, stdcall, stdcall-unwind, fastcall, fastcall-unwind, vectorcall, vectorcall-unwind, thiscall, thiscall-unwind, aapcs, aapcs-unwind, win64, win64-unwind, sysv64, sysv64-unwind, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, wasm, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted, rust-cold
error: aborting due to previous error

View file

@ -0,0 +1,21 @@
#![crate_type = "lib"]
extern "rust-cold" fn fu() {} //~ ERROR rust-cold is experimental
trait T {
extern "rust-cold" fn mu(); //~ ERROR rust-cold is experimental
extern "rust-cold" fn dmu() {} //~ ERROR rust-cold is experimental
}
struct S;
impl T for S {
extern "rust-cold" fn mu() {} //~ ERROR rust-cold is experimental
}
impl S {
extern "rust-cold" fn imu() {} //~ ERROR rust-cold is experimental
}
type TAU = extern "rust-cold" fn(); //~ ERROR rust-cold is experimental
extern "rust-cold" {} //~ ERROR rust-cold is experimental

View file

@ -0,0 +1,66 @@
error[E0658]: rust-cold is experimental and subject to change
--> $DIR/feature-gate-rust_cold_cc.rs:3:8
|
LL | extern "rust-cold" fn fu() {}
| ^^^^^^^^^^^
|
= note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information
= help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable
error[E0658]: rust-cold is experimental and subject to change
--> $DIR/feature-gate-rust_cold_cc.rs:6:12
|
LL | extern "rust-cold" fn mu();
| ^^^^^^^^^^^
|
= note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information
= help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable
error[E0658]: rust-cold is experimental and subject to change
--> $DIR/feature-gate-rust_cold_cc.rs:7:12
|
LL | extern "rust-cold" fn dmu() {}
| ^^^^^^^^^^^
|
= note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information
= help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable
error[E0658]: rust-cold is experimental and subject to change
--> $DIR/feature-gate-rust_cold_cc.rs:12:12
|
LL | extern "rust-cold" fn mu() {}
| ^^^^^^^^^^^
|
= note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information
= help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable
error[E0658]: rust-cold is experimental and subject to change
--> $DIR/feature-gate-rust_cold_cc.rs:16:12
|
LL | extern "rust-cold" fn imu() {}
| ^^^^^^^^^^^
|
= note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information
= help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable
error[E0658]: rust-cold is experimental and subject to change
--> $DIR/feature-gate-rust_cold_cc.rs:19:19
|
LL | type TAU = extern "rust-cold" fn();
| ^^^^^^^^^^^
|
= note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information
= help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable
error[E0658]: rust-cold is experimental and subject to change
--> $DIR/feature-gate-rust_cold_cc.rs:21:8
|
LL | extern "rust-cold" {}
| ^^^^^^^^^^^
|
= note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information
= help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -4,7 +4,7 @@ error[E0703]: invalid ABI: found `invalid-ab_isize`
LL | "invalid-ab_isize"
| ^^^^^^^^^^^^^^^^^^ invalid ABI
|
= help: valid ABIs: Rust, C, C-unwind, cdecl, cdecl-unwind, stdcall, stdcall-unwind, fastcall, fastcall-unwind, vectorcall, vectorcall-unwind, thiscall, thiscall-unwind, aapcs, aapcs-unwind, win64, win64-unwind, sysv64, sysv64-unwind, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, wasm, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted
= help: valid ABIs: Rust, C, C-unwind, cdecl, cdecl-unwind, stdcall, stdcall-unwind, fastcall, fastcall-unwind, vectorcall, vectorcall-unwind, thiscall, thiscall-unwind, aapcs, aapcs-unwind, win64, win64-unwind, sysv64, sysv64-unwind, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, wasm, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted, rust-cold
error: aborting due to previous error