mirror of
https://github.com/LLVMParty/striga
synced 2026-06-21 13:43:42 +00:00
Mark undef flag functions as memory(none), nounwind, willreturn
This allows for dead store elimination of the flags
This commit is contained in:
+11
-4
@@ -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] = {}
|
||||
|
||||
Reference in New Issue
Block a user