nllvmadd: fix not always forcing pointer constants in registers

There could have been a typeconversion around the pointerconstn/niln.
This was hidden because llvmtype fixed it up later, but with opaque
pointers it showed up again.
This commit is contained in:
Jonas Maebe 2022-06-11 11:15:34 +02:00
parent 2ce4f0baf5
commit d45076d9d6

View File

@ -129,15 +129,15 @@ implementation
{ comparison with pointer -> no immediate, as icmp can't handle pointer
immediates (except for nil as "null", but we don't generate that) }
if (nodetype in [equaln,unequaln,gtn,gten,ltn,lten]) and
((left.nodetype in [pointerconstn,niln]) or
(right.nodetype in [pointerconstn,niln])) then
(is_address(left.resultdef) or
is_address(right.resultdef)) then
allow_constant:=false;
inherited;
{ pointer - pointer = integer -> make all defs pointer since we can't
{ pointer - pointer = integer -> make all defs integer since we can't
subtract pointers }
if (nodetype=subn) and
(left.resultdef.typ=pointerdef) and
(right.resultdef.typ=pointerdef) then
is_address(left.resultdef) and
is_address(right.resultdef) then
begin
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,true);
hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,resultdef,true);
@ -145,13 +145,13 @@ implementation
{ pointer +/- integer -> make defs the same since a_op_* only gets a
single type as argument }
else if (nodetype in [addn,subn]) and
((left.resultdef.typ=pointerdef)<>(right.resultdef.typ=pointerdef)) then
(is_address(left.resultdef)<>is_address(right.resultdef)) then
begin
{ the result is a pointerdef -> typecast both arguments to pointer;
a_op_*_reg will convert them back to integer as needed }
if left.resultdef.typ<>pointerdef then
if not is_address(left.resultdef) then
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,true);
if right.resultdef.typ<>pointerdef then
if not is_address(right.resultdef) then
hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,resultdef,true);
end;
end;