Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 alpha 4/3/85; site ukma.UUCP
Path: utzoo!watmath!clyde!cbosgd!ukma!david
From: david@ukma.UUCP (David Herron, NPR Lover)
Newsgroups: net.bugs.4bsd
Subject: /lib/c2 optimizes calls instructions
Message-ID: <2064@ukma.UUCP>
Date: Sun, 18-Aug-85 21:43:46 EDT
Article-I.D.: ukma.2064
Posted: Sun Aug 18 21:43:46 1985
Date-Received: Tue, 20-Aug-85 21:22:24 EDT
Organization: U of Kentucky, Mathematical Sciences, Lexington KY
Lines: 96
Index: /lib/c2, BRL-Unix release 3, likely appears in other 4.?BSD.
Problem: Calls instructions have a format "calls ,".
The 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@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!