No-op implementation of vprintf

This should be replaced later, possibly with an SSA pass.
This commit is contained in:
Violet 2025-09-22 23:48:47 +00:00
commit 09e42ce4ed
4 changed files with 13 additions and 1 deletions

Binary file not shown.

View file

@ -842,4 +842,14 @@ typedef uint32_t ShflSyncResult __attribute__((ext_vector_type(2)));
return output.u32; return output.u32;
} }
int FUNC(vprintf)(const char *format __attribute__((unused)), void *vlist __attribute__((unused)))
{
// TODO: replace calls to vprintf with a raising pass to printf when we have a mechanism
// to write SSA passes
// Use https://github.com/ROCm/llvm-project/blob/99a81d16b9d811cadd420190bed16981a0a57bc6/llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp#L426
return -1;
}
} }

View file

@ -72,6 +72,7 @@ pub(crate) fn run<'input>(
} }
} }
if let Err(err) = module.verify() { if let Err(err) = module.verify() {
eprintln!("{}", module.print_module_to_string().to_str());
panic!("{:?}", err); panic!("{:?}", err);
} }
Ok(module) Ok(module)
@ -2853,6 +2854,7 @@ impl<'a> MethodEmitContext<'a> {
fn emit_trap(&mut self) -> Result<(), TranslateError> { fn emit_trap(&mut self) -> Result<(), TranslateError> {
self.emit_intrinsic(c"llvm.trap", None, None, vec![])?; self.emit_intrinsic(c"llvm.trap", None, None, vec![])?;
unsafe { LLVMBuildUnreachable(self.builder) };
Ok(()) Ok(())
} }

View file

@ -21,7 +21,7 @@ fn replace_with_ptx_impl<'input>(
resolver: &mut GlobalStringIdentResolver2<'input>, resolver: &mut GlobalStringIdentResolver2<'input>,
fn_name: SpirvWord, fn_name: SpirvWord,
) { ) {
let known_names = ["__assertfail"]; let known_names = ["__assertfail", "vprintf"];
if let Some(super::IdentEntry { if let Some(super::IdentEntry {
name: Some(name), .. name: Some(name), ..
}) = resolver.ident_map.get_mut(&fn_name) }) = resolver.ident_map.get_mut(&fn_name)