Skip to main content

empty_function

Function empty_function 

Source
pub fn empty_function(name: &str, params: &[Type], returns: &[Type]) -> Function
Expand description

Build an empty Cranelift function with the requested signature.

The returned Function has:

  • A SystemV calling convention. (The actual CC doesn’t matter for the IR-shape tests these fixtures support — the lowering passes don’t inspect it. SystemV is the workspace default for “any sane CC will do”.)
  • One entry block whose block-param list matches params 1:1 (same types, same order).
  • A terminating return of zero values. The caller is expected to either accept the empty return (e.g. void-returning functions) or to replace the terminator before lowering when a non-empty return is required. Replacing the terminator is uncommon in the wave-1 tests; most callers either use function_with_* (which already inserts a sensible return) or this helper for void fixtures.

The name argument is wrapped via UserFuncName::testcase so it shows up readably in Function::display() output during test failures.