mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-16 02:50:40 +01:00
* might_have_sideeffects gets flags: if mhs_exceptions is passed, nodes which might cause an exception are considered as having a side effect
git-svn-id: branches/laksen/riscv_new@39483 -
(cherry picked from commit 32a58ba7d1)
This commit is contained in:
parent
f6dee4c3e0
commit
4e5fb2c6a8
@ -1011,7 +1011,7 @@ implementation
|
||||
end;
|
||||
end
|
||||
{ short to full boolean evalution possible and useful? }
|
||||
else if not(might_have_sideeffects(right)) and not(cs_full_boolean_eval in localswitches) then
|
||||
else if not(might_have_sideeffects(right,[mhs_exceptions])) and not(cs_full_boolean_eval in localswitches) then
|
||||
begin
|
||||
case nodetype of
|
||||
andn,orn:
|
||||
|
||||
@ -54,6 +54,14 @@ interface
|
||||
then the parent node is processed again }
|
||||
pm_postandagain);
|
||||
|
||||
|
||||
tmhs_flag = (
|
||||
{ exceptions (overflow, sigfault etc.) are considered as side effect }
|
||||
mhs_exceptions
|
||||
);
|
||||
tmhs_flags = set of tmhs_flag;
|
||||
pmhs_flags = ^tmhs_flags;
|
||||
|
||||
foreachnodefunction = function(var n: tnode; arg: pointer): foreachnoderesult of object;
|
||||
staticforeachnodefunction = function(var n: tnode; arg: pointer): foreachnoderesult;
|
||||
|
||||
@ -117,7 +125,7 @@ interface
|
||||
function genloadfield(n: tnode; const fieldname: string): tnode;
|
||||
|
||||
{ returns true, if the tree given might have side effects }
|
||||
function might_have_sideeffects(n : tnode) : boolean;
|
||||
function might_have_sideeffects(n : tnode;const flags : tmhs_flags = []) : boolean;
|
||||
|
||||
{ returns true, if n contains nodes which might be conditionally executed }
|
||||
function has_conditional_nodes(n : tnode) : boolean;
|
||||
@ -1371,13 +1379,19 @@ implementation
|
||||
in_finalize_x,in_new_x,in_dispose_x,in_exit,in_copy_x,in_initialize_x,in_leave,in_cycle,
|
||||
in_and_assign_x_y,in_or_assign_x_y,in_xor_assign_x_y,in_sar_assign_x_y,in_shl_assign_x_y,
|
||||
in_shr_assign_x_y,in_rol_assign_x_y,in_ror_assign_x_y,in_neg_assign_x,in_not_assign_x])
|
||||
) or
|
||||
((mhs_exceptions in pmhs_flags(arg)^) and
|
||||
((n.nodetype in [derefn,vecn]) or
|
||||
((n.nodetype in [addn,subn,muln,divn,slashn,unaryminusn]) and (n.localswitches*[cs_check_overflow,cs_check_range]<>[]))
|
||||
)
|
||||
) then
|
||||
result:=fen_norecurse_true;
|
||||
end;
|
||||
|
||||
function might_have_sideeffects(n : tnode) : boolean;
|
||||
|
||||
function might_have_sideeffects(n : tnode; const flags : tmhs_flags) : boolean;
|
||||
begin
|
||||
result:=foreachnodestatic(n,@check_for_sideeffect,nil);
|
||||
result:=foreachnodestatic(n,@check_for_sideeffect,@flags);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user