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
2 changes: 1 addition & 1 deletion benches/ref_from_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8]) -> Option<&format::LocoPacket> {
fn bench_ref_from_bytes(source: &[u8]) -> Option<&format::LocoPacket> {
zerocopy::FromBytes::ref_from_bytes(source).ok()
}
2 changes: 1 addition & 1 deletion benches/ref_from_bytes.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_ref_from_bytes:
mov rdx, rsi
cmp rsi, 4
setb al
Expand Down
2 changes: 1 addition & 1 deletion benches/ref_from_bytes_with_elems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8], count: usize) -> Option<&format::LocoPacket> {
fn bench_ref_from_bytes_with_elems(source: &[u8], count: usize) -> Option<&format::LocoPacket> {
zerocopy::FromBytes::ref_from_bytes_with_elems(source, count).ok()
}
2 changes: 1 addition & 1 deletion benches/ref_from_bytes_with_elems.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_ref_from_bytes_with_elems:
movabs rax, 9223372036854775805
cmp rdx, rax
seta cl
Expand Down
2 changes: 1 addition & 1 deletion benches/ref_from_prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8]) -> Option<&format::LocoPacket> {
fn bench_ref_from_prefix(source: &[u8]) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_prefix(source) {
Ok((packet, _rest)) => Some(packet),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion benches/ref_from_prefix.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_ref_from_prefix:
xor edx, edx
mov eax, 0
test dil, 1
Expand Down
2 changes: 1 addition & 1 deletion benches/ref_from_prefix_with_elems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8], count: usize) -> Option<&format::LocoPacket> {
fn bench_ref_from_prefix_with_elems(source: &[u8], count: usize) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_prefix_with_elems(source, count) {
Ok((packet, _rest)) => Some(packet),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion benches/ref_from_prefix_with_elems.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_ref_from_prefix_with_elems:
movabs rax, 9223372036854775805
cmp rdx, rax
ja .LBB5_1
Expand Down
2 changes: 1 addition & 1 deletion benches/ref_from_suffix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8]) -> Option<&format::LocoPacket> {
fn bench_ref_from_suffix(source: &[u8]) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_suffix(source) {
Ok((_rest, packet)) => Some(packet),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion benches/ref_from_suffix.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_ref_from_suffix:
mov rdx, rsi
lea ecx, [rsi + rdi]
mov eax, edx
Expand Down
2 changes: 1 addition & 1 deletion benches/ref_from_suffix_with_elems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8], count: usize) -> Option<&format::LocoPacket> {
fn bench_ref_from_suffix_with_elems(source: &[u8], count: usize) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_suffix_with_elems(source, count) {
Ok((_rest, packet)) => Some(packet),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion benches/ref_from_suffix_with_elems.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_ref_from_suffix_with_elems:
movabs rax, 9223372036854775805
cmp rdx, rax
ja .LBB5_1
Expand Down
2 changes: 1 addition & 1 deletion benches/transmute_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ struct MinimalViableSource {
}

#[unsafe(no_mangle)]
fn codegen_test(source: &MinimalViableSource) -> &format::LocoPacket {
fn bench_transmute_ref(source: &MinimalViableSource) -> &format::LocoPacket {
zerocopy::transmute_ref!(source)
}
2 changes: 1 addition & 1 deletion benches/transmute_ref.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_transmute_ref:
mov rdx, rsi
mov rax, rdi
ret
2 changes: 1 addition & 1 deletion benches/try_ref_from_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8]) -> Option<&format::CocoPacket> {
fn bench_try_ref_from_bytes(source: &[u8]) -> Option<&format::CocoPacket> {
zerocopy::TryFromBytes::try_ref_from_bytes(source).ok()
}
2 changes: 1 addition & 1 deletion benches/try_ref_from_bytes.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_try_ref_from_bytes:
mov rdx, rsi
mov rax, rdi
cmp rsi, 4
Expand Down
2 changes: 1 addition & 1 deletion benches/try_ref_from_bytes_with_elems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8], count: usize) -> Option<&format::CocoPacket> {
fn bench_try_ref_from_bytes_with_elems(source: &[u8], count: usize) -> Option<&format::CocoPacket> {
zerocopy::TryFromBytes::try_ref_from_bytes_with_elems(source, count).ok()
}
2 changes: 1 addition & 1 deletion benches/try_ref_from_bytes_with_elems.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_try_ref_from_bytes_with_elems:
movabs rax, 9223372036854775805
cmp rdx, rax
seta cl
Expand Down
2 changes: 1 addition & 1 deletion benches/try_ref_from_prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8]) -> Option<&format::CocoPacket> {
fn bench_try_ref_from_prefix(source: &[u8]) -> Option<&format::CocoPacket> {
match zerocopy::TryFromBytes::try_ref_from_prefix(source) {
Ok((packet, _rest)) => Some(packet),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion benches/try_ref_from_prefix.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_try_ref_from_prefix:
xor edx, edx
mov eax, 0
test dil, 1
Expand Down
5 changes: 4 additions & 1 deletion benches/try_ref_from_prefix_with_elems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8], count: usize) -> Option<&format::CocoPacket> {
fn bench_try_ref_from_prefix_with_elems(
source: &[u8],
count: usize,
) -> Option<&format::CocoPacket> {
match zerocopy::TryFromBytes::try_ref_from_prefix_with_elems(source, count) {
Ok((packet, _rest)) => Some(packet),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion benches/try_ref_from_prefix_with_elems.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_try_ref_from_prefix_with_elems:
movabs rax, 9223372036854775805
cmp rdx, rax
ja .LBB5_1
Expand Down
2 changes: 1 addition & 1 deletion benches/try_ref_from_suffix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8]) -> Option<&format::CocoPacket> {
fn bench_try_ref_from_suffix(source: &[u8]) -> Option<&format::CocoPacket> {
match zerocopy::TryFromBytes::try_ref_from_suffix(source) {
Ok((_rest, packet)) => Some(packet),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion benches/try_ref_from_suffix.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_try_ref_from_suffix:
lea eax, [rsi + rdi]
cmp rsi, 4
setb cl
Expand Down
5 changes: 4 additions & 1 deletion benches/try_ref_from_suffix_with_elems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
mod format;

#[unsafe(no_mangle)]
fn codegen_test(source: &[u8], count: usize) -> Option<&format::CocoPacket> {
fn bench_try_ref_from_suffix_with_elems(
source: &[u8],
count: usize,
) -> Option<&format::CocoPacket> {
match zerocopy::TryFromBytes::try_ref_from_suffix_with_elems(source, count) {
Ok((_rest, packet)) => Some(packet),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion benches/try_ref_from_suffix_with_elems.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_try_ref_from_suffix_with_elems:
movabs rax, 9223372036854775805
cmp rdx, rax
ja .LBB5_1
Expand Down
2 changes: 1 addition & 1 deletion benches/try_transmute_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ struct MinimalViableSource {
}

#[unsafe(no_mangle)]
fn codegen_test(source: &MinimalViableSource) -> Option<&format::CocoPacket> {
fn bench_try_transmute_ref(source: &MinimalViableSource) -> Option<&format::CocoPacket> {
zerocopy::try_transmute_ref!(source).ok()
}
2 changes: 1 addition & 1 deletion benches/try_transmute_ref.x86-64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codegen_test:
bench_try_transmute_ref:
mov rdx, rsi
xor eax, eax
cmp word ptr [rdi], -16192
Expand Down
9 changes: 7 additions & 2 deletions tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@ fn run_codegen_test(bench_name: &str, target_cpu: &str, bless: bool) {
target_cpu,
"--simplify",
directive.arg(),
"codegen_test",
&format!("bench_{bench_name}"),
])
.output()
.expect("failed to execute process")
};

let test_directive = |directive: Directive| {
println!("{bench_name}");
Comment thread
joshlf marked this conversation as resolved.
let output = cargo_asm(&directive);
let actual_result = output.stdout;

if !(output.status.success()) {
panic!("{}", String::from_utf8_lossy(&output.stderr));
panic!(
"{}\n{}",
String::from_utf8_lossy(&actual_result),
String::from_utf8_lossy(&output.stderr)
);
}

let expected_file_path = {
Expand Down
Loading