Fix yet another optimizer bug

This commit is contained in:
Tom Eastep 2011-04-06 10:10:42 -07:00
parent 81437b2bb1
commit 6626ef06fb

View File

@ -1667,13 +1667,14 @@ sub delete_references( $ ) {
# #
sub replace_references( $$ ) { sub replace_references( $$ ) {
my ( $chainref, $target ) = @_; my ( $chainref, $target ) = @_;
my $tableref = $chain_table{$chainref->{table}}; my $tableref = $chain_table{$chainref->{table}};
my $count = 0; my $count = 0;
my $name = $chainref->{name}; my $name = $chainref->{name};
my $targetref = $tableref->{$target};
$name =~ s/\+/\\+/; $name =~ s/\+/\\+/;
if ( ! $tableref->{$target}{builtin} ) { if ( $targetref ) {
# #
# The target is a chain -- use the jump type from each referencing rule # The target is a chain -- use the jump type from each referencing rule
# #
@ -1683,7 +1684,7 @@ sub replace_references( $$ ) {
for ( @{$fromref->{rules}} ) { for ( @{$fromref->{rules}} ) {
$rule++; $rule++;
if ( s/ -([jg]) $name(\s|$)/ -$1 ${target}$2/ ) { if ( s/ -([jg]) $name(\s|$)/ -$1 ${target}$2/ ) {
add_reference ( $fromref, $tableref->{$target} ); add_reference ( $fromref, $targetref );
$count++; $count++;
trace( $fromref, 'R', $rule, $_ ) if $debug; trace( $fromref, 'R', $rule, $_ ) if $debug;
} }
@ -1693,7 +1694,7 @@ sub replace_references( $$ ) {
} }
} }
delete $tableref->{$target}{references}{$chainref->{name}}; delete $targetref->{references}{$chainref->{name}};
} else { } else {
# #
# The target is a builtin -- we must use '-j' # The target is a builtin -- we must use '-j'
@ -1704,7 +1705,6 @@ sub replace_references( $$ ) {
for ( @{$fromref->{rules}} ) { for ( @{$fromref->{rules}} ) {
$rule++; $rule++;
if ( s/ -[jg] $name(\s|$)/ -j ${target}$1/ ) { if ( s/ -[jg] $name(\s|$)/ -j ${target}$1/ ) {
add_reference ( $fromref, $tableref->{$target} );
$count++ ; $count++ ;
trace( $fromref, 'R', $rule, $_ ) if $debug; trace( $fromref, 'R', $rule, $_ ) if $debug;
} }
@ -1713,8 +1713,6 @@ sub replace_references( $$ ) {
delete $chainref->{references}{$fromref->{name}}; delete $chainref->{references}{$fromref->{name}};
} }
} }
delete $tableref->{$target}{references}{$chainref->{name}};
} }
progress_message " $count references to chain $chainref->{name} replaced" if $count; progress_message " $count references to chain $chainref->{name} replaced" if $count;