mdt@YAHI.STANFORD.EDU (Michael Tiemann) (02/03/89)
Date: Thu, 02 Feb 89 03:40:52 -0800 From: "Douglas C. Schmidt" <sources%crimee.ics.uci.edu@paris.ics.uci.edu> Michael, This is really off the wall, and probably a waste of time, but some code generated with gcc 1.33 is getting a segmentation fault on the sparc. I'm fairly certain it's the compiler, since cc has no problems with it, and the system I'm compiling is very portable and has been around for a long time (it's a C version of Knuth's Tex program generated with a Web-to-C converter). The debugger claims the program fails on the following line: curval = curval * radix + d ; where the variables are: long curval; char radix; char d; Here's the relevant output from gcc sethi %hi(_radix),%g1 ldsb [%g1+%lo(_radix)],%o0 sethi %hi(_curval),%g1 ld [%g1+%lo(_curval)],%o3 call .mul,2 mov %o3,%o1 mov %o0,%o2 sll %l1,0x18,%o0 sra %o0,0x18,%o0 add %o2,%o0,%o0 st %o0,[%g1+%lo(_curval)] And here's the output from cc (which doesn't seg fault) sethi %hi(_radix),%o1 ldsb [%o1+%lo(_radix)],%o1 sethi %hi(_curval),%o0 ld [%o0+%lo(_curval)],%o0 call .mul,2 nop mov %i4,%l1 add %o0,%l1,%l2 sethi %hi(_curval),%l3 st %l2,[%l3+%lo(_curval)] If this is too much of a pain, just ignore it. I don't know sparc well enough to figure out what's going wrong, so if you can figure it out from this skimpy sample that's fine, otherwise, we'll just have to wait.... Doug p.s. No options were used for the compilation, in particular -meager was *not* applied. This problem is very easily fixed: Change the function `output_mul_insn' to include somewhere, a call to CC_STATUS_INIT: char * output_mul_insn (operands, unsignedp) rtx *operands; int unsignedp; { int lucky1 = ((unsigned)REGNO (operands[1]) - 8) <= 1; int lucky2 = ((unsigned)REGNO (operands[2]) - 8) <= 1; CC_STATUS_INIT; /* this forgotten in virgin 1.33. */ if (lucky1) if (lucky2) output_asm_insn ("call .mul,2\n\tnop", operands); Michael