@@ -246,34 +246,25 @@ fn execute_instruction(
246246 // Storing indexed with update, clear updated register (second arg)
247247 registers[ rel] = RegisterContent :: Unknown ;
248248 }
249- (
250- Opcode :: Stb
251- | Opcode :: Sth
252- | Opcode :: Stw
253- | Opcode :: Stbx
254- | Opcode :: Sthx
255- | Opcode :: Stwx
256- | Opcode :: Stfs
257- | Opcode :: Stfd ,
258- _,
259- _,
260- _,
261- ) => {
262- // Storing, does not change registers
263- }
264249 ( Opcode :: Lmw , Argument :: GPR ( target) , _, _) => {
265250 // `lmw` overwrites all registers from rd to r31.
266251 for reg in target. 0 ..31 {
267252 registers[ GPR ( reg) ] = RegisterContent :: Unknown ;
268253 }
269254 }
270255 ( _, Argument :: GPR ( a) , _, _) => {
271- // Other operations which write to GPR a
272- registers[ a] = RegisterContent :: Unknown ;
256+ // Store instructions don't modify the GPR
257+ if !is_store_instruction ( * op) {
258+ // Other operations which write to GPR a
259+ registers[ a] = RegisterContent :: Unknown ;
260+ }
273261 }
274262 ( _, Argument :: FPR ( a) , _, _) => {
275- // Other operations which write to FPR a
276- registers[ a] = RegisterContent :: Unknown ;
263+ // Store instructions don't modify the FPR
264+ if !is_store_instruction ( * op) {
265+ // Other operations which write to FPR a
266+ registers[ a] = RegisterContent :: Unknown ;
267+ }
277268 }
278269 ( _, _, _, _) => { }
279270 }
@@ -546,23 +537,24 @@ fn generate_flow_analysis_result(
546537 let index = addr / 4 ;
547538 let ppc750cl:: ParsedIns { mnemonic : _, args } = ins. simplified ( ) ;
548539
540+ // If we're already showing relocations on a line don't also show data flow
541+ let reloc = relocations. iter ( ) . find ( |r| ( r. address & !3 ) == ins_address) ;
542+
549543 // Special case to show float and double constants on the line where
550544 // they are being loaded.
551545 // We need to do this before we break out on showing relocations in the
552546 // subsequent if statement.
553- if ins. op == ppc750cl:: Opcode :: Lfs || ins. op == ppc750cl:: Opcode :: Lfd {
554- if let Some ( reloc) = relocations. iter ( ) . find ( |r| ( r. address as u32 & !3 ) == ins_address as u32 ) {
555- let content = get_register_content_from_reloc ( reloc, obj, ins. op ) ;
556- if matches ! ( content, RegisterContent :: FloatConstant ( _) | RegisterContent :: DoubleConstant ( _) ) {
557- analysis_result. set_argument_value_at_address (
558- ins_address,
559- 1 ,
560- FlowAnalysisValue :: Text ( format ! ( "{}" , content) ) ,
561- ) ;
547+ if let ( ppc750cl:: Opcode :: Lfs | ppc750cl:: Opcode :: Lfd , Some ( reloc) ) = ( ins. op , reloc) {
548+ let content = get_register_content_from_reloc ( reloc, obj, ins. op ) ;
549+ if matches ! ( content, RegisterContent :: FloatConstant ( _) | RegisterContent :: DoubleConstant ( _) ) {
550+ analysis_result. set_argument_value_at_address (
551+ ins_address,
552+ 1 ,
553+ FlowAnalysisValue :: Text ( format ! ( "{}" , content) ) ,
554+ ) ;
562555
563- // Don't need to show any other data flow if we're showing that
564- continue ;
565- }
556+ // Don't need to show any other data flow if we're showing that
557+ continue ;
566558 }
567559 }
568560
@@ -586,11 +578,6 @@ fn generate_flow_analysis_result(
586578 }
587579 }
588580
589- // If we're already showing relocations on a line don't also show data flow
590- if relocations. iter ( ) . any ( |r| ( r. address & !3 ) == ins_address) {
591- continue ;
592- }
593-
594581 let is_store = is_store_instruction ( ins. op ) ;
595582 for ( arg_index, arg) in args. into_iter ( ) . enumerate ( ) {
596583 // Hacky shorthand for determining which arguments are sources,
@@ -607,12 +594,21 @@ fn generate_flow_analysis_result(
607594 _ => None ,
608595 } ;
609596 let analysis_value = match content {
610- Some ( RegisterContent :: Symbol ( s) ) => obj. symbols . get ( s) . map ( |sym| {
611- FlowAnalysisValue :: Text ( clamp_text_length (
612- sym. demangled_name . as_ref ( ) . unwrap_or ( & sym. name ) . clone ( ) ,
613- 20 ,
614- ) )
615- } ) ,
597+ Some ( RegisterContent :: Symbol ( s) ) => if reloc. is_none ( ) {
598+ // Only symbols if there isn't already a relocation, because
599+ // code other than the data flow analysis will be showing
600+ // the symbol for a relocation on the line it is for. If we
601+ // also showed it as data flow analysis value we would be
602+ // showing redundant information.
603+ obj. symbols . get ( s) . map ( |sym| {
604+ FlowAnalysisValue :: Text ( clamp_text_length (
605+ sym. demangled_name . as_ref ( ) . unwrap_or ( & sym. name ) . clone ( ) ,
606+ 20 ,
607+ ) )
608+ } )
609+ } else {
610+ None
611+ } ,
616612 Some ( RegisterContent :: InputRegister ( reg) ) => {
617613 let reg_name = match arg {
618614 Argument :: GPR ( _) => format ! ( "input_r{reg}" ) ,
0 commit comments