Skip to content

Commit 1d7aadb

Browse files
committed
fix profiling bug
1 parent c4fbcc3 commit 1d7aadb

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

cobc/ChangeLog

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11

2-
2022-12-08 Simon Sobisch <[email protected]>
2+
2025-01-03 Fabrice Le Fessant <[email protected]>
3+
4+
* typeck.c (build_evaluate): fix a bug where EVALUATE fails in
5+
profiling mode. The reason was that a check for a last GOTO
6+
statement is not correctly written, because it was actually
7+
checking either a GOTO or not a statement, which was failing
8+
for true for instructions added by profiling. Fixed by
9+
checking only that the last statement is a GOTO.
10+
11+
2024-12-08 Simon Sobisch <[email protected]>
312

413
* cobc.c (process_command_line): fix leak for --copy and -include parsing
514

cobc/typeck.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10019,6 +10019,7 @@ build_evaluate (cb_tree subject_list, cb_tree case_list, cb_tree goto_end_label)
1001910019
cb_source_line = old_line;
1002010020

1002110021
} else {
10022+
int need_end_goto = 1 ;
1002210023
c2 = stmt;
1002310024
/* Check if last statement is GO TO */
1002410025
for (c3 = stmt; c3; c3 = CB_CHAIN (c3)) {
@@ -10028,11 +10029,14 @@ build_evaluate (cb_tree subject_list, cb_tree case_list, cb_tree goto_end_label)
1002810029
}
1002910030
if (c3 && CB_VALUE (c3) && CB_STATEMENT_P (CB_VALUE (c3))) {
1003010031
c3 = CB_STATEMENT (CB_VALUE (c3))->body;
10031-
if (c3 && CB_VALUE (c3) && !CB_GOTO_P (CB_VALUE(c3))) {
10032-
/* Append the jump */
10033-
c2 = cb_list_add (stmt, goto_end_label);
10032+
if (c3 && CB_VALUE (c3) && CB_GOTO_P (CB_VALUE(c3))) {
10033+
need_end_goto = 0 ;
1003410034
}
1003510035
}
10036+
if ( need_end_goto ){
10037+
/* Append the jump */
10038+
c2 = cb_list_add (stmt, goto_end_label);
10039+
}
1003610040
cb_emit (cb_build_if (cb_build_cond (c1), c2, NULL, STMT_WHEN));
1003710041
build_evaluate (subject_list, CB_CHAIN (case_list), goto_end_label);
1003810042
}

0 commit comments

Comments
 (0)