Commit 058bfe53 by Iain Sandoe

make ObjC do LTO.

gcc/
	PR objc/44140
	* config/darwin.c (output_objc_section_asm_op): Save and restore
	section when outputting ObjC section list.

testsuite/

	PR objc/44140
	* objc.dg/lto/trivial-1_0.m: New.
	* objc.dg/lto/lto.exp: New.
	* obj-c++.dg/lto/trivial-1_0.mm: New.
	* obj-c++.dg/lto/lto.exp: New.
	* objc.dg/symtab-1.m: Adjust sizes.
	* objc.dg/image-info.m: Do not run for gnu-runtime.

gcc/objc/

	PR objc/44140
	* objc-act.c: build_objc_string_decl() remove declaration.
	(finish_var_decl): Remove forcing of var output and marking
	as "Used". 
	(init_def_list): Use integer_zero_node. 
	(init_objc_symtab): Use integer_zero_node, make the short
	integer type specific on relevant nodes.
	(generate_objc_symtab_decl): Remove call to 
	forward_declare_categories().  Use null_pointer_node where
	appropriate.  
	(build_module_descriptor): Comment and mark this item as 
	DECL_PRESERVE_P. 
	(generate_static_references): Use gcc_unreachable instead of
	abort (). 
	(diagnose_missing_method): New.
	(build_next_selector_translation_table): New.
	(build_gnu_selector_translation_table): New.
	(add_objc_string): Merge code from build_objc_string_decl...
	... and delete build_objc_string_decl().
	(generate_dispatch_table): Make integer types explicit.
	(generate_category): Pass implent and arrange for the data
	to be extracted within the routine.  Do not start new vars, 
	but finish the ones collcted during parsing.
	(generate_shared_structures): Likewise.
	(finish_objc):  Reorder code so that we finish variables before
	referencing them.  Save the global data before calling meta-data
	creation routines, and pass the current reference to the two 
	main routines.  Only call generate_objc_image_info () for the 
	NeXT runtime.
	(generate_classref_translation_entry): Comment on and make this
	item DECL_PRESERVE_P.
	(handle_class_ref): Use varpool interfaces, comment on and make
	this item DECL_PRESERVE_P.
	(handle_impent): Likewise.
	(generate_objc_image_info): Only generate when the content is 
	non-zero.  Make integer types explict.

From-SVN: r162030
parent 0571e6db
2010-07-10 Iain Sandoe <iains@gcc.gnu.org>
PR objc/44140
* config/darwin.c (output_objc_section_asm_op): Save and restore
section when outputting ObjC section list.
2010-07-09 Jan Hubicka <jh@suse.cz> 2010-07-09 Jan Hubicka <jh@suse.cz>
* lto-streamer-out.c (produce_symtab): Do not write alias cgraph/varpool * lto-streamer-out.c (produce_symtab): Do not write alias cgraph/varpool
......
...@@ -99,6 +99,7 @@ output_objc_section_asm_op (const void *directive) ...@@ -99,6 +99,7 @@ output_objc_section_asm_op (const void *directive)
section is requested. */ section is requested. */
if (! been_here) if (! been_here)
{ {
section *saved_in_section = in_section;
static const enum darwin_section_enum tomark[] = static const enum darwin_section_enum tomark[] =
{ {
/* written, cold -> hot */ /* written, cold -> hot */
...@@ -129,6 +130,7 @@ output_objc_section_asm_op (const void *directive) ...@@ -129,6 +130,7 @@ output_objc_section_asm_op (const void *directive)
been_here = true; been_here = true;
for (i = 0; i < ARRAY_SIZE (tomark); i++) for (i = 0; i < ARRAY_SIZE (tomark); i++)
switch_to_section (darwin_sections[tomark[i]]); switch_to_section (darwin_sections[tomark[i]]);
switch_to_section (saved_in_section);
} }
output_section_asm_op (directive); output_section_asm_op (directive);
} }
......
2010-07-10 Iain Sandoe <iains@gcc.gnu.org>
PR objc/44140
* objc-act.c: build_objc_string_decl() remove declaration.
(finish_var_decl): Remove forcing of var output and marking
as "Used".
(init_def_list): Use integer_zero_node.
(init_objc_symtab): Use integer_zero_node, make the short
integer type specific on relevant nodes.
(generate_objc_symtab_decl): Remove call to
forward_declare_categories(). Use null_pointer_node where
appropriate.
(build_module_descriptor): Comment and mark this item as
DECL_PRESERVE_P.
(generate_static_references): Use gcc_unreachable instead of
abort ().
(diagnose_missing_method): New.
(build_next_selector_translation_table): New.
(build_gnu_selector_translation_table): New.
(add_objc_string): Merge code from build_objc_string_decl...
... and delete build_objc_string_decl().
(generate_dispatch_table): Make integer types explicit.
(generate_category): Pass implent and arrange for the data
to be extracted within the routine. Do not start new vars,
but finish the ones collcted during parsing.
(generate_shared_structures): Likewise.
(finish_objc): Reorder code so that we finish variables before
referencing them. Save the global data before calling meta-data
creation routines, and pass the current reference to the two
main routines. Only call generate_objc_image_info () for the
NeXT runtime.
(generate_classref_translation_entry): Comment on and make this
item DECL_PRESERVE_P.
(handle_class_ref): Use varpool interfaces, comment on and make
this item DECL_PRESERVE_P.
(handle_impent): Likewise.
(generate_objc_image_info): Only generate when the content is
non-zero. Make integer types explict.
2010-07-03 Nathan Froyd <froydnj@codesourcery.com> 2010-07-03 Nathan Froyd <froydnj@codesourcery.com>
PR objc/24867 PR objc/24867
......
2010-07-10 Iain Sandoe <iains@gcc.gnu.org>
PR objc/44140
* objc.dg/lto/trivial-1_0.m: New.
* objc.dg/lto/lto.exp: New.
* obj-c++.dg/lto/trivial-1_0.mm: New.
* obj-c++.dg/lto/lto.exp: New.
* objc.dg/symtab-1.m: Adjust sizes.
* objc.dg/image-info.m: Do not run for gnu-runtime.
2010-07-09 Bernd Schmidt <bernds@codesourcery.com> 2010-07-09 Bernd Schmidt <bernds@codesourcery.com>
* gcc.dg/pr32370.c: Allow another kind of error message. * gcc.dg/pr32370.c: Allow another kind of error message.
......
# Copyright (C) 2010 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
#
# Based on gcc/testsuite/gcc.dg/lto/lto.exp.
# Test link-time optimization across multiple files.
#
# Programs are broken into multiple files. Each one is compiled
# separately with LTO information. The final executable is generated
# by collecting all the generated object files using regular LTO or WHOPR.
if $tracelevel then {
strace $tracelevel
}
# Load procedures from common libraries.
load_lib standard.exp
load_lib obj-c++-dg.exp
# Load the language-independent compabibility support procedures.
load_lib lto.exp
# If LTO has not been enabled, bail.
if { ![check_effective_target_lto] } {
return
}
global LTO_OPTIONS
set LTO_OPTIONS [list \
{-O0 -fwhopr -fgnu-runtime} \
{-O2 -fwhopr -fgnu-runtime} \
{-O0 -flto -fgnu-runtime} \
{-O2 -flto -fgnu-runtime} \
]
obj-c++_init
lto_init no-mathlib
# Define an identifier for use with this suite to avoid name conflicts
# with other lto tests running at the same time.
set sid "obj_cpp_lto"
set tests [lsort [glob -nocomplain $srcdir/$subdir/*_0.mm]]
# Main loop.
foreach src $tests {
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $src] then {
continue
}
lto-execute $src $sid
}
# darwin targets can also run code with the NeXT runtime.
if [istarget "*-*-darwin*" ] {
set LTO_OPTIONS [list \
{-O0 -fwhopr -fnext-runtime} \
{-O2 -fwhopr -fnext-runtime} \
{-O0 -flto -fnext-runtime} \
{-O2 -flto -fnext-runtime} \
]
foreach src $tests {
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $src] then {
continue
}
lto-execute $src $sid
}
}
lto_finish
/* { dg-lto-do run } */
/* { dg-skip-if "Needs OBJC2 ABI" { "*-*-darwin*" && lp64 } { "*" } { "" } } */
extern "C" {
extern int printf (char *,...) ;
extern void abort (void) ;
}
typedef struct objc_class *Class;
struct objc_class {
Class isa;
/* other stuff... */
} ;
@interface myRootObject {
@public
Class isa;
}
+initialize;
+(Class)class;
@end
@implementation myRootObject
++initialize {
return self;
}
+(Class)class {
return (Class)self;
}
@end
int main(void)
{
Class cl = [myRootObject class];
if (cl != (Class)0) {
printf((char *)"trivial OK\n");
return 0;
}
abort () ;
}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */ /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
/* { dg-do compile { target { *-*-darwin* } } } */ /* { dg-do compile { target { *-*-darwin* } } } */
/* { dg-skip-if "NeXT-only" { *-*-* } { "-fgnu-runtime" } { "" } } */
/* { dg-options "-freplace-objc-classes" } */ /* { dg-options "-freplace-objc-classes" } */
#include "../objc-obj-c++-shared/Object1.h" #include "../objc-obj-c++-shared/Object1.h"
......
# Copyright (C) 2010 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
#
# Based on gcc/testsuite/gcc.dg/lto/lto.exp.
# Test link-time optimization across multiple files.
#
# Programs are broken into multiple files. Each one is compiled
# separately with LTO information. The final executable is generated
# by collecting all the generated object files using regular LTO or WHOPR.
if $tracelevel then {
strace $tracelevel
}
# Load procedures from common libraries.
load_lib standard.exp
load_lib objc-dg.exp
# Load the language-independent compabibility support procedures.
load_lib lto.exp
# If LTO has not been enabled, bail.
if { ![check_effective_target_lto] } {
return
}
global LTO_OPTIONS
set LTO_OPTIONS [list \
{-O0 -fwhopr -fgnu-runtime} \
{-O2 -fwhopr -fgnu-runtime} \
{-O0 -flto -fgnu-runtime} \
{-O2 -flto -fgnu-runtime} \
]
objc_init
lto_init no-mathlib
# Define an identifier for use with this suite to avoid name conflicts
# with other lto tests running at the same time.
set sid "objc_lto"
set tests [lsort [glob -nocomplain $srcdir/$subdir/*_0.m]]
# Main loop.
foreach src $tests {
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $src] then {
continue
}
lto-execute $src $sid
}
# darwin targets can also run code with the NeXT runtime.
if [istarget "*-*-darwin*" ] {
set LTO_OPTIONS [list \
{-O0 -fwhopr -fnext-runtime} \
{-O2 -fwhopr -fnext-runtime} \
{-O0 -flto -fnext-runtime} \
{-O2 -flto -fnext-runtime} \
]
foreach src $tests {
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $src] then {
continue
}
lto-execute $src $sid
}
}
lto_finish
/* { dg-lto-do run } */
/* { dg-skip-if "" { "*-*-darwin*" && lp64 } { "*" } { "" } } */
extern int printf (char *,...) ;
typedef struct objc_class *Class;
struct objc_class {
Class isa;
/* other stuff... */
} ;
@interface myRootObject {
@public
Class isa;
}
+initialize;
+(Class)class;
@end
@implementation myRootObject
++initialize {
return self;
}
+(Class)class {
return (Class)self;
}
@end
int main(void)
{
[myRootObject class];
printf("trivial OK\n");
return 0;
}
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
-(void)checkValues { } -(void)checkValues { }
@end @end
/* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.long\t0\n\t.long\t0\n\t.word\t2\n\t.word\t0\n\t.long\tL_OBJC_CLASS_Derived.*\n\t.long\tL_OBJC_CLASS_Base.*\n" { target { i?86-*-darwin* && { ! lp64 } } } } } */ /* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.long\t0\n\t.long\t0\n\t.word\t2\n\t.word\t0\n\t.long\tL_OBJC_CLASS_Derived.*\n\t.long\tL_OBJC_CLASS_Base.*\n" { target { *86*-*-darwin* && { ! lp64 } } } } } */
/* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.long\t0\n\t.long\t0\n\t.short\t2\n\t.short\t0\n\t.long\tL_OBJC_CLASS_Derived.*\n\t.long\tL_OBJC_CLASS_Base.*\n" { target { powerpc-*-darwin* && { ! lp64 } } } } } */ /* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.long\t0\n\t.long\t0\n\t.short\t2\n\t.short\t0\n\t.long\tL_OBJC_CLASS_Derived.*\n\t.long\tL_OBJC_CLASS_Base.*\n" { target { powerpc*-*-darwin* && { ! lp64 } } } } } */
/* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.quad\t0\n\t.long\t0\n\t.space 4\n\t.word\t2\n\t.word\t0\n\t.space 4\n\t.quad\tL_OBJC_CLASS_Derived.*\n\t.quad\tL_OBJC_CLASS_Base.*\n" { target { *-*-darwin* && { lp64 } } } } } */ /* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.quad\t0\n\t.quad\t0\n\t.word\t2\n\t.word\t0\n\t.space 4\n\t.quad\tL_OBJC_CLASS_Derived.*\n\t.quad\tL_OBJC_CLASS_Base.*\n" { target { *86*-*-darwin* && { lp64 } } } } } */
/* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.quad\t0\n\t.quad\t0\n\t.short\t2\n\t.short\t0\n\t.space 4\n\t.quad\tL_OBJC_CLASS_Derived.*\n\t.quad\tL_OBJC_CLASS_Base.*\n" { target { powerpc*-*-darwin* && { lp64 } } } } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment