LLVM: remove use of getelementptr in make_simple_ref_ptr

We cannot safely infer whether it needs to be indirect or not there,
it should be done at a higher level if appropriate.
This commit is contained in:
Jonas Maebe 2023-01-07 22:11:36 +01:00
parent 51fdbb5524
commit 00a5d30300

View File

@ -2066,7 +2066,6 @@ implementation
hreg1,
hreg2: tregister;
tmpref: treference;
pointedsize: asizeint;
begin
if ref.alignment=0 then
internalerror(2016072203);
@ -2079,41 +2078,9 @@ implementation
result:=ref;
exit;
end;
case ptrdef.typ of
pointerdef:
begin
pointedsize:=tpointerdef(ptrdef).pointeddef.size;
{ void, formaldef }
if pointedsize=0 then
pointedsize:=1;
end;
else
begin
{ pointedsize is only used if the offset <> 0, to see whether we
can use getelementptr if it's an exact multiple -> set pointedsize
to a value that will never be a multiple as we can't "index" other
types }
pointedsize:=ref.offset+1;
end;
end;
hreg2:=getaddressregister(list,ptrdef);
{ symbol+offset or base+offset with offset a multiple of the size ->
use getelementptr }
if (ref.index=NR_NO) and
(ref.offset mod pointedsize=0) then
begin
ptrindex:=ref.offset div pointedsize;
if assigned(ref.symbol) then
reference_reset_symbol(tmpref,ref.symbol,0,ref.alignment,ref.volatility)
else
reference_reset_base(tmpref,ptrdef,ref.base,0,ref.temppos,ref.alignment,ref.volatility);
list.concat(taillvm.getelementptr_reg_size_ref_size_const(hreg2,ptrdef,tmpref,ptruinttype,ptrindex,assigned(ref.symbol)));
reference_reset_base(result,ptrdef,hreg2,0,ref.temppos,ref.alignment,ref.volatility);
exit;
end;
{ for now, perform all calculations using plain pointer arithmetic. Later
we can look into optimizations based on getelementptr for structured
accesses (if only to prevent running out of virtual registers).
{ At this levevl, perform all calculations using plain pointer arithmetic.
Optimizations based on getelementptr for structured accesses need to be
performed at the node tree level.
Assumptions:
* symbol/base register: always type "ptrdef"