Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/asm/asm/comments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ assembly-output: emit-asm
//@ only-x86_64
// Check that comments in assembly get passed

#![crate_type = "lib"]

// CHECK-LABEL: "test_comments":
#[no_mangle]
pub fn test_comments() {
// CHECK: example comment
unsafe { core::arch::asm!("nop // example comment") };
}
24 changes: 24 additions & 0 deletions tests/asm/naked-functions/x86_64-naked-fn-no-cet-prolog.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ compile-flags: -C no-prepopulate-passes -Zcf-protection=full
//@ assembly-output: emit-asm
//@ needs-asm-support
//@ only-x86_64

#![crate_type = "lib"]

use std::arch::naked_asm;

// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",
// meaning "no prologue whatsoever, no, really, not one instruction."
// Unfortunately, x86's control-flow enforcement, specifically indirect branch protection,
// works by using an instruction for each possible landing site,
// and LLVM implements this via making sure of that.
#[no_mangle]
#[unsafe(naked)]
pub extern "sysv64" fn will_halt() -> ! {
// CHECK-NOT: endbr{{32|64}}
// CHECK: hlt
naked_asm!("hlt")
}

// what about aarch64?
// "branch-protection"=false
12 changes: 12 additions & 0 deletions tests/asm/x86_64-sse_crc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ only-x86_64
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type staticlib -Ctarget-feature=+sse4.2

// CHECK-LABEL: banana
// CHECK: crc32
#[no_mangle]
pub unsafe fn banana(v: u8) -> u32 {
use std::arch::x86_64::*;
let out = !0u32;
_mm_crc32_u8(out, v)
}
Loading