mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 05:44:58 +00:00
Fix a code generation bug: it called
Estimated hours taken: 0.5 hours for the fix, 8 hours debugging (plus a similar amount of Zoltan's time debugging) string_switch.m: Fix a code generation bug: it called code_info__generate_failure from the wrong spot, and so used the wrong exprn_info. This meant that the code generated by generate_failure contained incorrect register shuffling, since it thought the variables were in different locations to where they really were.
This commit is contained in:
@@ -71,6 +71,12 @@ string_switch__generate(Cases, Var, CodeModel, _CanFail, EndLabel, Code) -->
|
|||||||
code_info__release_reg(SlotR),
|
code_info__release_reg(SlotR),
|
||||||
code_info__release_reg(StringR),
|
code_info__release_reg(StringR),
|
||||||
|
|
||||||
|
% Generate the code for when the hash lookup fails.
|
||||||
|
% This must be done before gen_hash_slots, since
|
||||||
|
% we want to use the exprn_info corresponding to
|
||||||
|
% the start of the switch, not to the end of the last case.
|
||||||
|
code_info__generate_failure(FailCode),
|
||||||
|
|
||||||
% Generate the code etc. for the hash table
|
% Generate the code etc. for the hash table
|
||||||
%
|
%
|
||||||
string_switch__gen_hash_slots(0, TableSize, HashSlotsMap, CodeModel,
|
string_switch__gen_hash_slots(0, TableSize, HashSlotsMap, CodeModel,
|
||||||
@@ -105,10 +111,6 @@ string_switch__generate(Cases, Var, CodeModel, _CanFail, EndLabel, Code) -->
|
|||||||
"no match, so fail"
|
"no match, so fail"
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
code_info__generate_failure(FailCodeA),
|
|
||||||
code_info__generate_forced_saves(FailCodeB),
|
|
||||||
{ FailCode = tree(FailCodeA, FailCodeB) },
|
|
||||||
code_info__remake_with_store_map,
|
|
||||||
{
|
{
|
||||||
JumpCode = node([
|
JumpCode = node([
|
||||||
label(JumpLabel) -
|
label(JumpLabel) -
|
||||||
@@ -120,7 +122,8 @@ string_switch__generate(Cases, Var, CodeModel, _CanFail, EndLabel, Code) -->
|
|||||||
% Collect all the generated code fragments together
|
% Collect all the generated code fragments together
|
||||||
{ Code = tree(tree(VarCode, tree(HashLookupCode, FailCode)),
|
{ Code = tree(tree(VarCode, tree(HashLookupCode, FailCode)),
|
||||||
tree(JumpCode, SlotsCode))
|
tree(JumpCode, SlotsCode))
|
||||||
}.
|
},
|
||||||
|
code_info__remake_with_store_map.
|
||||||
|
|
||||||
:- pred string_switch__hash_cases(cases_list, int, map(int, cases_list)).
|
:- pred string_switch__hash_cases(cases_list, int, map(int, cases_list)).
|
||||||
:- mode string_switch__hash_cases(in, in, out) is det.
|
:- mode string_switch__hash_cases(in, in, out) is det.
|
||||||
|
|||||||
Reference in New Issue
Block a user