Skip to content

Commit 62a502a

Browse files
authored
asm: fix trace logging of XMM registers (bytecodealliance#10538)
* asm: fix trace logging of XMM registers Along the lines of bytecodealliance#10389 and bytecodealliance#10478, this change fixes the case where an XMM register is pretty-printed during logging, which may happen before register allocation has provided a true HW register. Fixes bytecodealliance#10529. * Run filetests with logging enabled
1 parent 62fa364 commit 62a502a

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

cranelift/assembler-x64/src/xmm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ impl<R: AsReg> Xmm<R> {
2525
}
2626

2727
/// Return the register name.
28-
pub fn to_string(&self) -> &str {
29-
enc::to_string(self.enc())
28+
pub fn to_string(&self) -> String {
29+
self.0.to_string(None)
3030
}
3131
}
3232

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// This test runs the filetests with logging enabled.
2+
///
3+
/// In order to avoid issues like [#10529] and similar, we re-run the filetests
4+
/// with logging enabled. This pretty-prints instructions prior to register
5+
/// allocation, when they may not have real HW registers assigned. Ideally this
6+
/// test is temporary while we work out details in the `cranelift-assembler-x64`
7+
/// crate (TODO).
8+
///
9+
/// [#10529]: https://github.com/bytecodealliance/wasmtime/issues/10529
10+
#[test]
11+
fn logged_filetests() -> anyhow::Result<()> {
12+
let _ = pretty_env_logger::formatted_builder()
13+
.filter_module(
14+
"cranelift_codegen::machinst::lower",
15+
log::LevelFilter::Trace,
16+
)
17+
.is_test(true)
18+
.init();
19+
cranelift_filetests::run(false, false, &["filetests".into(), "docs".into()])?;
20+
Ok(())
21+
}

0 commit comments

Comments
 (0)