site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Organization: University of Michigan User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 I've had a problem with a rebuild of pfe-0.33.30 with gcc 3.3 under MacOS 10.3.4, which worked fine in 2.95.2 under MacOS 10.2.x. It seems to boil down to an illegal (I think) save/restore of one or more registers declared as global variables, which I've distilled into the example below. Among several register problems, my initial scan of Bugzilla doesn't show this, but maybe I missed it (or maybe I'm just misunderstanding something). The assembly output was produced by cc -S -c -Wall -no-cpp-precomp -O3 $1.c Other optimizations give the same problem. ----- testreg.c --------- #include <locale.h> register int *testreg asm ("r29"); int *ext_func (int *p); void test_reg_save_restore (int *p) { setlocale (LC_ALL, "C"); testreg = ext_func(p); } ------ testreg.s --------- .section __TEXT,__text,regular,pure_instructions .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 .data .cstring .align 2 LC0: .ascii "C\0" .section __TEXT,__text,regular,pure_instructions .align 2 .align 2 .globl _test_reg_save_restore .section __TEXT,__text,regular,pure_instructions .align 2 _test_reg_save_restore: mflr r4 bcl 20,31,"L00000000001$pb" "L00000000001$pb": stmw r28,-16(r1) mflr r31 addis r2,r31,ha16(LC0-"L00000000001$pb") stw r4,8(r1) mr r28,r3 stwu r1,-80(r1) la r4,lo16(LC0-"L00000000001$pb")(r2) li r3,0 bl L_setlocale$stub mr r3,r28 bl L_ext_func$stub lwz r2,88(r1) addi r1,r1,80 mr r29,r3 mtlr r2 lmw r28,-16(r1) blr [the rest snipped] ----------------------- Note that registers r28-r31 are saved and then restored on top of the load into the global variable register r29. If I read correctly, the 3.3 documentation says otherwise. Here's a quote from "Using the GNU Compiler Collection" in the "Defining Global Register Variables" section (3.3 documentation distributed by Apple): -------------- You can define a global register variable in GNU C like this: register int *foo asm ("a5"); Here a5 is the name of the register which should be used. Choose a register which is normally saved and restored by function calls on your machine, so that library routines will not clobber it. ... Defining a global register variable in a certain register reserves that register entirely for this use, at least within the current compilation. The register will not be allocated for any other purpose in the functions in the current compilation. The register will not be saved and restored by these functions. Stores into this register are never deleted even if they would appear to be dead, but references may be deleted or moved or simplified. -------------- Am I off base here? Thanks for any insights! -- David _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
David N. Williams