Mark undef flag functions as memory(none), nounwind, willreturn

This allows for dead store elimination of the flags
This commit is contained in:
Duncan Ogilvie
2026-05-14 16:28:32 +02:00
parent 3c671c5cc2
commit ebdf8d3b3c
+11 -4
View File
@@ -133,10 +133,17 @@ class Semantics:
self.call_handler = self.module.add_function("__striga_call", helper_ty)
self.ret_handler = self.module.add_function("__striga_ret", helper_ty)
self.syscall_handler = self.module.add_function("__striga_syscall", helper_ty)
self.undef_flags = {
name: self.module.add_function(f"__striga_undef_{name}", undef_flag_ty)
for name in FLAGS
}
def add_undef_flag_helper(name: str) -> Function:
helper = self.module.add_function(f"__striga_undef_{name}", undef_flag_ty)
# Undefined-flag helpers model arbitrary values, not side effects.
# Match Remill's symbolic/undefined helper annotations so calls can
# be deleted after their flag stores are proven dead.
helper.attributes.add_memory("none")
helper.attributes.add("nounwind")
helper.attributes.add("willreturn")
return helper
self.undef_flags = {name: add_undef_flag_helper(name) for name in FLAGS}
# Set per function lifted
self.insn_blocks: dict[int, BasicBlock] = {}