* ignore vmtloadaddrnodes created in dead strip removed code

for wpo

git-svn-id: trunk@12364 -
This commit is contained in:
Jonas Maebe 2008-12-14 18:56:02 +00:00
parent f104ec1346
commit 47ba5b19ec
3 changed files with 81 additions and 5 deletions

1
.gitattributes vendored
View File

@ -7606,6 +7606,7 @@ tests/test/opt/twpo1.pp svneol=native#text/plain
tests/test/opt/twpo2.pp svneol=native#text/plain
tests/test/opt/twpo3.pp svneol=native#text/plain
tests/test/opt/twpo4.pp svneol=native#text/plain
tests/test/opt/twpo5.pp svneol=native#text/plain
tests/test/opt/uwpo2.pp svneol=native#text/plain
tests/test/packages/fcl-base/tgettext1.pp svneol=native#text/plain
tests/test/packages/fcl-db/assertions.pas svneol=native#text/plain

View File

@ -134,6 +134,7 @@ implementation
cutils,verbose,globals,
symconst,symbase,defutil,defcmp,
nbas,nutils,
wpobase,
htypechk,pass_1,ncal,nld,ncon,ncnv,cgbase,procinfo
;
@ -171,11 +172,16 @@ implementation
expectloc:=LOC_REGISTER;
if left.nodetype<>typen then
firstpass(left)
{ keep track of which classes might be instantiated via a classrefdef }
else if (left.resultdef.typ=classrefdef) then
tobjectdef(tclassrefdef(left.resultdef).pointeddef).register_maybe_created_object_type
else if (left.resultdef.typ=objectdef) then
tobjectdef(left.resultdef).register_maybe_created_object_type;
else if not assigned(current_procinfo) or
(po_inline in current_procinfo.procdef.procoptions) or
wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname) then
begin
{ keep track of which classes might be instantiated via a classrefdef }
if (left.resultdef.typ=classrefdef) then
tobjectdef(tclassrefdef(left.resultdef).pointeddef).register_maybe_created_object_type
else if (left.resultdef.typ=objectdef) then
tobjectdef(left.resultdef).register_maybe_created_object_type
end
end;

69
tests/test/opt/twpo5.pp Normal file
View File

@ -0,0 +1,69 @@
{ %target=darwin,linux,freebsd,solaris }
{ %wpoparas=devirtcalls,optvmts,symbolliveness }
{ %wpopasses=2 }
{ %opt=-CX -XX -Xs- }
{ not enabled for windows yet because symbolliveness doesn't work there without
installing "nm" (until implemented by way of internal linker there)
}
{$mode objfpc}
{ test case that can be optimised based on taking into account dead code
stripping
}
type
tbase = class
procedure test; virtual;
end;
tchild1 = class(tbase)
procedure test; override;
end;
tchild2 = class(tbase)
procedure test; override;
end;
procedure tbase.test;
begin
halt(1);
end;
var
a: longint;
cc: class of tbase;
procedure tchild1.test;
begin
if a<>1 then
halt(2);
end;
procedure tchild2.test;
begin
if a<>2 then
halt(3);
end;
procedure notcalled;
var
bb: tbase;
begin
cc:=tchild2;
bb:=cc.create;
bb.test;
bb.free;
end;
var
bb: tbase;
begin
cc:=tchild1;
bb:=cc.create;
a:=1;
bb.test;
a:=2;
bb.free;
end.