@@ -150,7 +150,8 @@ def buildast(args: argparse.Namespace) -> NoReturn:
150150 xpatchresultsfile = args .patch_results_file
151151 hide_globals : bool = args .hide_globals
152152 hide_annotations : bool = args .hide_annotations
153- show_reachingdefs : str = args .show_reachingdefs
153+ show_reachingdefs : bool = args .show_reachingdefs
154+ reachingdefs_registers : List [str ] = args .reachingdefs_registers
154155 output_reachingdefs : str = args .output_reachingdefs
155156 fileformat : str = args .format
156157 verbose : bool = args .verbose
@@ -349,13 +350,26 @@ def buildast(args: argparse.Namespace) -> NoReturn:
349350 # Introduce ssa variables for all reaching definitions referenced in
350351 # xdata records for all instructions in the function. Locations that
351352 # have a common user are merged. Types are provided by lhs_types.
352- astinterface .introduce_ssa_variables (
353+ untyped = astinterface .introduce_ssa_variables (
353354 f .rdef_location_partition (), f .register_lhs_types , f .lhs_names )
354355
355356 # Introduce stack variables for all stack buffers with types
356357 astinterface .introduce_stack_variables (
357358 f .stackframe , f .stack_variable_types )
358359
360+ regsuntyped : List [str ] = []
361+ for (reg , varlocs ) in untyped .items ():
362+ for (var , locs ) in varlocs .items ():
363+ if len (locs ) == 1 and locs [0 ] == "init" :
364+ continue
365+ if "_spill" in var :
366+ continue
367+ if reg == "SP" :
368+ continue
369+ # print(" Untyped: " + reg + ": " + var + " [" + ",".join(locs) + "]")
370+ if not reg in regsuntyped :
371+ regsuntyped .append (reg )
372+
359373 astfunction = ASTInterfaceFunction (
360374 faddr , fname , f , astinterface , patchevents = patchevents )
361375
@@ -396,14 +410,18 @@ def buildast(args: argparse.Namespace) -> NoReturn:
396410 UC .print_error ("\n Specify a file to save the reaching defs" )
397411 continue
398412
399- register = show_reachingdefs
400- if not register in f .rdef_location_partition ():
401- UC .print_status_update (
402- "Register " + register + " not found in rdeflocations" )
403- continue
413+ if len (reachingdefs_registers ) == 0 :
414+ reachingdefs_registers = regsuntyped
404415
405- print_reachingdefs (
406- app , astinterface , output_reachingdefs , fileformat , f , register )
416+ for register in reachingdefs_registers :
417+ if not register in f .rdef_location_partition ():
418+ UC .print_status_update (
419+ "Register " + register + " not found in rdeflocations" )
420+ continue
421+
422+ for reg in reachingdefs_registers :
423+ print_reachingdefs (
424+ app , astinterface , output_reachingdefs + "__" + reg , fileformat , f , reg )
407425
408426 else :
409427 UC .print_error ("Unable to find function " + faddr )
@@ -510,21 +528,23 @@ def print_reachingdefs(
510528 else :
511529 printgraphs .append (dg )
512530
513- pdffilename = UD .print_dot_subgraphs (
514- app .path ,
515- "paths" ,
516- filename ,
517- fileformat ,
518- printgraphs )
519-
520- UC .print_status_update ("Printed " + pdffilename )
521- if len (possibly_spurious_rdefs ) > 0 :
522- print ("Possibly spurious reachingdefs to be removed: " )
523- print ("~" * 80 )
524- for (rdef , iaddr ) in set (possibly_spurious_rdefs ):
525- if not (rdef , iaddr ) in legitimate_rdefs :
526- print (" rdefloc: " + rdef + "; useloc: " + iaddr )
527- print ("~" * 80 )
531+ if len (printgraphs ) > 0 :
532+ pdffilename = UD .print_dot_subgraphs (
533+ app .path ,
534+ "paths" ,
535+ filename ,
536+ fileformat ,
537+ printgraphs )
538+
539+ UC .print_status_update ("Printed " + pdffilename )
540+ if len (possibly_spurious_rdefs ) > 0 :
541+ print ("\n Possibly spurious reachingdefs to be removed for register "
542+ + register + ": " )
543+ print ("~" * 80 )
544+ for (rdef , iaddr ) in set (possibly_spurious_rdefs ):
545+ if not (rdef , iaddr ) in legitimate_rdefs :
546+ print (" rdefloc: " + rdef + "; useloc: " + iaddr )
547+ print ("~" * 80 )
528548
529549 # print("\nLegitimate reaching defs:")
530550 # for (rdef, iaddr) in set(legitimate_rdefs):
0 commit comments