This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch reimplements -mlongcall support for Darwin/PPC, using branch islands.
Most linkers that support branch islands (e.g. AIX) will create them when required. Since the Darwin linker has a strict policy of "never create code," the Darwin version obliges the compiler to create branch islands wherever they may be needed, and the linker will delete unnecessary ones.
The patch creates branch islands for every direct CALL when the "-mlongcall" commandline option is present (indirect CALLs are not affected). The usual PPC "bl foo" instruction is replaced with "jbsr foo, L42"; "jbsr" is a Darwin-ism that means "bl foo" if foo is reachable, and "bl L42" otherwise. "L42" is a local label on a branch island appended to the current function body. The Apple/NeXT GCC has supported this for -static code for many years ("-mlong-branch"); it's used to build device drivers for Darwin. This patch is sensitive to -fPIC and -static (and the Darwin-only -mdynamic-no-pic), and generates suitable code for each case.
The current Darwin linker does not yet discard unnecessary branch islands, but this has been promised in a future release. In the meantime, this patch allows the creation of very large programs that were previously unlinkable on Darwin/PPC.
The current Darwin/PPC crt1.o needs some simple tweaks to support large programs that use -mlongcall; the fix exists inside Apple, and it's promised for a future release.
Tested with a bootstrap and make check of C, C++, ObjC (on the trunk and tree-ssa branch). I also ran a bootstrap/check with "-mlongcall" wired on; this flushed out the one testcase failure. The patch includes a fix for that Darwin/PPC-specific testcase. I also inserted an inline-asm into the compiler source that created a 128-Mbyte "hole" in the executable, and I was able to link and run the resulting compiler; using the debugger, I verified that some of the branch islands were obliged to jump over the hole. The resulting (huge) compiler binary demonstrably works, although I didn't run a complete make-check on it. Also, a trivial test of #pragma longcall (1) worked as expected.
stuart hastings Apple Computer
Attachment:
gcc-tssa.diffs.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |