/lib/c2 optimizes calls instructions
David Herron, NPR Lover
david at ukma.UUCP
Mon Aug 19 11:43:46 AEST 1985
Index: /lib/c2, BRL-Unix release 3, likely appears in other 4.?BSD.
Problem: Calls instructions have a format "calls <const-#-of-args>,<addr>".
The <const-#-of-args> argument will sometimes be "optimized" into
a register reference. This isn't necessary, and breaks the
massager which helps create the code in the kernel.
Repeat-by: Compile the following program segment:
b() {}
a()
{
register int i;
i = 0;
b();
}
For which you get:
LL0:
.data
.text
.align 1
.globl _b
_b:
.word L12
jbr L14
L15:
ret
.set L12,0x0
L14:
jbr L15
.data
.text
.align 1
.globl _a
_a:
.word L17
jbr L19
L20:
clrl r11
calls $0,_b
ret
.set L17,0x800
L19:
jbr L20
After running /lib/c2 -i:
.data
LL0:.data
.text
.align 1
.globl _b
.set L12,0x0
.data
.text
_b:.word L12
ret
.align 1
.globl _a
.set L17,0x800
.data
.text
_a:.word L17
clrl r11
calls r11,_b
ret
Notice that the $0 has been changed to r11.
Fix: I was going to provide a fix, but I took one look at the code for
c2 and decided I wasn't that brave :-). I did notice a few
places in c21.c which looked to be likely candidates for fixing.
What I suggest is that c2 be taught not to optimize calls instructions.
Work-around: Add rules to asm.sed or inline (as appropriate) to match
all the possibilities that calls might be optimized into.
Since this is non-trivial I would really prefer for c2 to be fixed.
Could someone who still runs 4.2BSD (and 4.3BSD too) check to see if the
bug is that widely spread? And System V while yer at it..... :-)
--
--- David Herron
--- ARPA-> ukma!david at ANL-MCS.ARPA
--- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david
--- {ihnp4,decvax,ucbvax}!cbosgd!ukma!david
Hackin's in me blood. My mother was known as Miss Hacker before she married!
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list