mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-15 02:49:36 +02:00
+ check whether all br instructions, generated by goto point to a pascal goto label
This commit is contained in:
parent
31dff18a61
commit
3defa34470
@ -56,6 +56,8 @@ uses
|
||||
{ taicpu }
|
||||
|
||||
taicpu = class(tai_cpu_abstract_sym)
|
||||
is_br_generated_by_goto: boolean;
|
||||
|
||||
constructor op_none(op : tasmop);
|
||||
|
||||
constructor op_reg(op : tasmop;_op1 : tregister);
|
||||
|
@ -59,7 +59,7 @@ interface
|
||||
procedure postprocess_code; override;
|
||||
procedure set_first_temp_offset;override;
|
||||
procedure add_goto_target(l : tasmlabel);
|
||||
function is_goto_target(l : tasmlabel): Boolean;
|
||||
function is_goto_target(l : tasmsymbol): Boolean;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -918,10 +918,36 @@ implementation
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure check_goto_br_instructions(list: TAsmList);
|
||||
var
|
||||
hp: tai;
|
||||
begin
|
||||
hp:=tai(list.first);
|
||||
while assigned(hp) do
|
||||
begin
|
||||
if (hp.typ=ait_instruction) and (taicpu(hp).is_br_generated_by_goto) then
|
||||
begin
|
||||
if (taicpu(hp).opcode<>a_br) or
|
||||
(taicpu(hp).ops<>1) or
|
||||
(taicpu(hp).oper[0]^.typ<>top_ref) or
|
||||
(taicpu(hp).oper[0]^.ref^.offset<>0) or
|
||||
(taicpu(hp).oper[0]^.ref^.base<>NR_NO) or
|
||||
(taicpu(hp).oper[0]^.ref^.index<>NR_NO) or
|
||||
(taicpu(hp).oper[0]^.ref^.symbol=nil) then
|
||||
internalerror(2023102203);
|
||||
if not is_goto_target(taicpu(hp).oper[0]^.ref^.symbol) then
|
||||
internalerror(2023102204);
|
||||
end;
|
||||
hp:=tai(hp.next);
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
localslist: TAsmList;
|
||||
labels_resolved: Boolean;
|
||||
begin
|
||||
check_goto_br_instructions(aktproccode);
|
||||
|
||||
localslist:=prepare_locals;
|
||||
|
||||
replace_local_frame_pointer(aktproccode);
|
||||
@ -963,7 +989,7 @@ implementation
|
||||
FGotoTargets.Add(l.Name,l);
|
||||
end;
|
||||
|
||||
function tcpuprocinfo.is_goto_target(l: tasmlabel): Boolean;
|
||||
function tcpuprocinfo.is_goto_target(l: tasmsymbol): Boolean;
|
||||
begin
|
||||
result:=FGotoTargets.FindIndexOf(l.Name)<>-1;
|
||||
end;
|
||||
|
@ -1934,8 +1934,12 @@ implementation
|
||||
end;
|
||||
|
||||
procedure thlcgwasm.a_jmp_always_pascal_goto(list: TAsmList; l: tasmlabel);
|
||||
var
|
||||
br_ins: taicpu;
|
||||
begin
|
||||
list.concat(taicpu.op_sym(a_br,l));
|
||||
br_ins:=taicpu.op_sym(a_br,l);
|
||||
br_ins.is_br_generated_by_goto:=true;
|
||||
list.concat(br_ins);
|
||||
end;
|
||||
|
||||
procedure thlcgwasm.a_loadfpu_ref_ref(list: TAsmList; fromsize, tosize: tdef; const ref1, ref2: treference);
|
||||
|
Loading…
Reference in New Issue
Block a user