Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 1265f7e

Browse files
authored
Merge pull request #339 from Alexendoo/asm
Add some inline ASM crashes
2 parents 9937a18 + 3bdca6e commit 1265f7e

File tree

8 files changed

+76
-6
lines changed

8 files changed

+76
-6
lines changed

ices/13368.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#![feature(asm)]
1+
#![feature(llvm_asm)]
22

33
fn main() {
44
let arr: [u8; 16];
5-
unsafe { asm!("" : "=m"(arr)); }
5+
unsafe { llvm_asm!("" : "=m"(arr)); }
66
println!("{:?}", arr);
77
}

ices/13520.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#![feature(asm)]
1+
#![feature(llvm_asm)]
22

33
fn main() {
44
let x = ();
55
unsafe {
66
let p: *const () = &x;
7-
asm!("" :: "r"(*p));
7+
llvm_asm!("" :: "r"(*p));
88
}
99
}

ices/15402.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#![feature(asm)]
1+
#![feature(llvm_asm)]
22

33
#[repr(packed)]
44
struct Bitfield<T>(T);
55

66
fn test()->(Bitfield<u32>,Bitfield<u32>) {
77
let mut out=(Bitfield(0),Bitfield(0));
8-
unsafe{asm!("" : "={eax}"(out.0), "={ebx}"(out.1))};
8+
unsafe{llvm_asm!("" : "={eax}"(out.0), "={ebx}"(out.1))};
99
out
1010
}
1111

ices/59184.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#![feature(llvm_asm)]
2+
3+
fn main()
4+
{
5+
println!("Hello, world! {}", read_after_raising_any_exceptions());
6+
}
7+
8+
#[inline(never)]
9+
pub fn read_after_raising_any_exceptions() -> u16
10+
{
11+
unsafe
12+
{
13+
// See <https://github.com/HJLebbink/asm-dude/wiki/FSTCW_FNSTCW>.
14+
let mut control_word: u16;
15+
llvm_asm!
16+
(
17+
"fstcw $0"
18+
:
19+
// Output constraints.
20+
"=m"(control_word)
21+
:
22+
// Input constraints.
23+
:
24+
// Clobbers.
25+
:
26+
// Options.
27+
"volatile"
28+
);
29+
control_word
30+
}
31+
}

ices/66223.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
rustc -C opt-level=3 - << 'END'
4+
#![feature(llvm_asm)]
5+
6+
unsafe fn _mm512_set1_epi64(a: i64) {
7+
llvm_asm! {
8+
"vpbroadcastq zmm0{k1}, $0"
9+
:: "m"(a)
10+
:: "intel"
11+
}
12+
}
13+
14+
fn main() {
15+
unsafe { _mm512_set1_epi64(123); }
16+
}
17+
END

ices/68136-1.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(llvm_asm)]
2+
3+
extern "C" fn foo() { }
4+
5+
fn main() {
6+
unsafe {
7+
llvm_asm!("callq $0" :: "s"(foo) :: "volatile");
8+
}
9+
}

ices/68136-2.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(llvm_asm)]
2+
3+
extern "C" fn foo() { }
4+
5+
fn main() {
6+
let x: usize;
7+
unsafe {
8+
llvm_asm!("movq $1, $0" : "=r"(x) : "r"(foo));
9+
}
10+
assert!(x != 0);
11+
}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ impl ICE {
5151
outcome: match output.status.code() {
5252
Some(0) => Outcome::NoError,
5353
Some(101) => Outcome::ICEd, // An ICE will cause an error code of 101
54+
// Bash uses 128+N for processes terminated by signal N
55+
Some(x) if x > 128 => Outcome::ICEd,
5456
Some(_) => Outcome::Errored,
5557
None => Outcome::ICEd, // If rustc receives a signal treat is as an ICE
5658
},

0 commit comments

Comments
 (0)