mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 02:31:49 +01:00 
			
		
		
		
	* ignore vmtloadaddrnodes created in dead strip removed code
for wpo git-svn-id: trunk@12364 -
This commit is contained in:
		
							parent
							
								
									f104ec1346
								
							
						
					
					
						commit
						47ba5b19ec
					
				
							
								
								
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							| @ -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/twpo2.pp svneol=native#text/plain | ||||||
| tests/test/opt/twpo3.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/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/opt/uwpo2.pp svneol=native#text/plain | ||||||
| tests/test/packages/fcl-base/tgettext1.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 | tests/test/packages/fcl-db/assertions.pas svneol=native#text/plain | ||||||
|  | |||||||
| @ -134,6 +134,7 @@ implementation | |||||||
|       cutils,verbose,globals, |       cutils,verbose,globals, | ||||||
|       symconst,symbase,defutil,defcmp, |       symconst,symbase,defutil,defcmp, | ||||||
|       nbas,nutils, |       nbas,nutils, | ||||||
|  |       wpobase, | ||||||
|       htypechk,pass_1,ncal,nld,ncon,ncnv,cgbase,procinfo |       htypechk,pass_1,ncal,nld,ncon,ncnv,cgbase,procinfo | ||||||
|       ; |       ; | ||||||
| 
 | 
 | ||||||
| @ -171,11 +172,16 @@ implementation | |||||||
|          expectloc:=LOC_REGISTER; |          expectloc:=LOC_REGISTER; | ||||||
|          if left.nodetype<>typen then |          if left.nodetype<>typen then | ||||||
|            firstpass(left) |            firstpass(left) | ||||||
|          { keep track of which classes might be instantiated via a classrefdef } |          else if not assigned(current_procinfo) or | ||||||
|          else if (left.resultdef.typ=classrefdef) then |              (po_inline in current_procinfo.procdef.procoptions) or | ||||||
|            tobjectdef(tclassrefdef(left.resultdef).pointeddef).register_maybe_created_object_type |              wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname) then | ||||||
|          else if (left.resultdef.typ=objectdef) then |            begin | ||||||
|            tobjectdef(left.resultdef).register_maybe_created_object_type; |              { 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; |       end; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										69
									
								
								tests/test/opt/twpo5.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								tests/test/opt/twpo5.pp
									
									
									
									
									
										Normal 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. | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Jonas Maebe
						Jonas Maebe