mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-20 16:31:04 +00:00
Estimated hours taken: 2
Branches: main, release
Fix a bug reported by Michael Day. The bug was that when frameopt wanted
to find out whether a block of instructions referred to stack variables,
it did not look past pragma_c_code LLDS instructions. As a result, the
generated code included a (redundant) assignment to a stack variable
in a section of code that, after frameopt, did not have a stack frame
anymore. It therefore overwrote part of its caller's stack frame, which
caused a crash.
compiler/opt_util.m:
Fix the auxiliary predicate used by frameopt.
tests/hard_coded/prince_frameopt.{m,exp}:
tests/hard_coded/prince_frameopt_css.m:
tests/hard_coded/prince_frameopt_css.style.m:
The new test case (a three module program).
tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
Enable the new test case, and compile it with the options required
to show the bug if it exists.
39 lines
620 B
Mathematica
39 lines
620 B
Mathematica
:- module prince_frameopt_css.
|
|
|
|
:- interface.
|
|
|
|
:- import_module string, int, float.
|
|
|
|
:- include_module prince_frameopt_css.style.
|
|
|
|
:- type length
|
|
---> absolute(float).
|
|
|
|
:- type value
|
|
---> ident(string)
|
|
; percent(number).
|
|
|
|
:- type number
|
|
---> int(int)
|
|
; float(float).
|
|
|
|
:- func get_length(value) = length is det.
|
|
:- func get_percent(value) = float is semidet.
|
|
|
|
:- implementation.
|
|
|
|
get_length(V) = L :-
|
|
( if V = ident("zero") then
|
|
L = absolute(0.0)
|
|
else
|
|
L = absolute(1.0)
|
|
).
|
|
|
|
get_percent(percent(N0)) = N :-
|
|
(
|
|
N0 = int(N1),
|
|
N = float(N1)
|
|
;
|
|
N0 = float(N)
|
|
).
|