@@ -54,7 +54,7 @@ class DerivationCache {
5454 return hasChanges ;
5555 }
5656
57- addDerivationEntry (
57+ updateDerivationEntry (
5858 derivedVar : Place ,
5959 sourcesIds : Set < IdentifierId > ,
6060 typeOfValue : TypeOfValue ,
@@ -93,12 +93,19 @@ class DerivationCache {
9393 }
9494
9595 const existingValue = this . cache . get ( derivedVar . identifier . id ) ;
96- if (
97- existingValue === undefined ||
98- ! this . isDerivationEqual ( existingValue , newValue )
99- ) {
96+ if ( existingValue === undefined ) {
10097 this . cache . set ( derivedVar . identifier . id , newValue ) ;
10198 this . hasChanges = true ;
99+ } else if ( ! this . isDerivationEqual ( existingValue , newValue ) ) {
100+ this . cache . set ( derivedVar . identifier . id , {
101+ place : newValue . place ,
102+ sourcesIds : new Set ( [
103+ ...existingValue . sourcesIds ,
104+ ...newValue . sourcesIds ,
105+ ] ) ,
106+ typeOfValue : joinValue ( existingValue . typeOfValue , newValue . typeOfValue ) ,
107+ } ) ;
108+ this . hasChanges = true ;
102109 }
103110 }
104111
@@ -232,7 +239,7 @@ function recordPhiDerivations(
232239 }
233240
234241 if ( typeOfValue !== 'ignored' ) {
235- context . derivationCache . addDerivationEntry (
242+ context . derivationCache . updateDerivationEntry (
236243 phi . place ,
237244 sourcesIds ,
238245 typeOfValue ,
@@ -320,7 +327,7 @@ function recordInstructionDerivations(
320327 }
321328
322329 for ( const lvalue of eachInstructionLValue ( instr ) ) {
323- context . derivationCache . addDerivationEntry ( lvalue , sources , typeOfValue ) ;
330+ context . derivationCache . updateDerivationEntry ( lvalue , sources , typeOfValue ) ;
324331 }
325332
326333 for ( const operand of eachInstructionOperand ( instr ) ) {
@@ -331,7 +338,7 @@ function recordInstructionDerivations(
331338 case Effect . ConditionallyMutateIterator :
332339 case Effect . Mutate : {
333340 if ( isMutable ( instr , operand ) ) {
334- context . derivationCache . addDerivationEntry (
341+ context . derivationCache . updateDerivationEntry (
335342 operand ,
336343 sources ,
337344 typeOfValue ,
0 commit comments