Move return_at_end out of Settings and into the wasm FuncEnvironment. (#547)
* Move `return_at_end` out of Settings and into the wasm FuncEnvironment. The `return_at_end` flag supports users that want to append a custom epilogue to Cranelift-produced functions. It arranges for functions to always return via a single return statement at the end, and users are expected to remove this return to append their code. This patch makes two changes: - First, introduce a `fallthrough_return` instruction and use that instead of adding a `return` at the end. That's simpler than having users remove the `return` themselves. - Second, move this setting out of the Settings and into the wasm FuncEnvironment. This flag isn't something the code generator uses, it's something that the wasm translator uses. The code generator needs to preserve the property, however we can give the `fallthrough_return` instruction properties to ensure this as needed, such as marking it non-cloneable.
This commit is contained in:
@@ -234,6 +234,16 @@ x_return = Instruction(
|
||||
""",
|
||||
ins=rvals, is_return=True, is_terminator=True)
|
||||
|
||||
fallthrough_return = Instruction(
|
||||
'fallthrough_return', r"""
|
||||
Return from the function by fallthrough.
|
||||
|
||||
This is a specialized instruction for use where one wants to append
|
||||
a custom epilogue, which will then perform the real return. This
|
||||
instruction has no encoding.
|
||||
""",
|
||||
ins=rvals, is_return=True, is_terminator=True)
|
||||
|
||||
FN = Operand(
|
||||
'FN',
|
||||
entities.func_ref,
|
||||
|
||||
@@ -65,16 +65,6 @@ colocated_libcalls = BoolSetting(
|
||||
they can use more efficient addressing.
|
||||
""")
|
||||
|
||||
return_at_end = BoolSetting(
|
||||
"""
|
||||
Generate functions with at most a single return instruction at the
|
||||
end of the function.
|
||||
|
||||
This guarantees that functions do not have any internal return
|
||||
instructions. Either they never return, or they have a single return
|
||||
instruction at the end.
|
||||
""")
|
||||
|
||||
avoid_div_traps = BoolSetting(
|
||||
"""
|
||||
Generate explicit checks around native division instructions to avoid
|
||||
|
||||
Reference in New Issue
Block a user