mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
This fixes Github issue #133. The bug occurred after jumpopt.m transformed code of the form % if (Cond) L1 % r1 = MR_FALSE when followed immediately by % <epilog> % ... % L1: % r1 = MR_TRUE % <epilog> into code of the form % r1 = Cond % <epilog> The transformation left both epilogs in the instruction sequence, even though at least the first, and probably both, were now being dead code. The problem arose because the compiler did not clean up either dead epilogue, leading to failed assertion in a later code optimization pass. compiler/optimize.m: Fix the bug by forcing the execution of the passes that clean up dead code if jumpopt makes any changes to the instruction sequence. compiler/jumpopt.m: When replacing an if_val instruction whose target and fallthrough lead to two different semidet epilogues (one assigning 0 to r1 and one assigning 1) with a single epilogue assigning to r1 the value of a bool expression and then returning, delete all the instructions following the if_val up to but not including the next label. This is because replacing the if_val by by the new epilogue makes those instructions unreachable. The diffs for the next two files are not part of the fix, but I noticed the need for them while hunting the bug. compiler/opt_debug.m: Give a predicate a more descriptive name, and simplify its code. Make the dumps of computed goto instructions more readable, both by printing each target on its own line, and by printing the value corresponding to each target. compiler/hlds_out_type_table.m: Format the description of arguments' offsets in heap cells in a way that is more readable. Print just one offset for an argument in the usual case where it is not preceded by any nonarguments such as type_infos/typeclass_infos (i.e. if its arg-only offset is the same as its offset from the start of the heap cell). If those two offsets differ, then include a description of each offset with its value. Move the description of each du type's kind (i.e. whether it is an enum type, notag type etc) to *before* the description of its function symbols. tests/hard_coded/gh133.{m,exp}: A test case for this bug, derived from the one in github issue #133. tests/hard_coded/Mmakefile: Enable the new test case.
2 lines
29 B
Plaintext
2 lines
29 B
Plaintext
Test succeeded. Y = bar01(5)
|