Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: comp.bugs.4bsd Subject: 4.3BSD c2 mangles some asm statements (with fix) Message-ID: <7229@elsie.UUCP> Date: Tue, 2-Dec-86 11:54:20 EST Article-I.D.: elsie.7229 Posted: Tue Dec 2 11:54:20 1986 Date-Received: Tue, 2-Dec-86 20:23:27 EST Organization: NIH-LEC, Bethesda, MD Lines: 84 Keywords: c asm bsd Index: lib/c2/c21.c 4.3 Fix Description: The 4.3BSD C optimizer (c2) mangles some asm statements. Repeat-By: Do a "cc -S -O" of a file containing the lines: static k(i) { asm("chmk 4(ap)"); } static e(i) { asm("chme 4(ap)"); } and note the contents of the resulting assembly-language file: .data .text .set L12,0x0 .data .text .set L17,0x0 .data .text LL0:.align 1 _k:.word L12 L2000000:chmk 4(ap) ret .align 1 _e:.word L17 jbr L2000000 where the "chme" instruction in the original source has disappeared. Fix: Here are changes to the function "equop" in the file "c21.c" that will avoid false optimizations of the kind illustrated above. The changes also cause the optimizer to (unconditionally) produce a warning message if your source code would be incorrectly compiled on uncorrected 4.3 systems. The changes are conditionally compiled based on "ASWAS." As always, should you or any. . .sorry, wrong tape. As always, the trade secret status of the code involved precludes a clearer posting. . . . if (cp1==0 && cp2==0) #ifdef ASWAS return(1); #else /* !ASWAS */ if (p1->pop == p2->pop) return 1; else goto dowarn; #endif /* !ASWAS */ if (cp1==0 || cp2==0) return(0); while (*cp1 == *cp2++) if (*cp1++ == 0) #ifdef ASWAS return(1); #else /* !ASWAS */ if (p1->pop == p2->pop) return 1; else { dowarn: (void) fprintf(stderr, "c2: warning--\"%s %s\" & \"%s %s\" are the same to standard 4.3 C optimizer\n", p1->pop->opstring, (p1->code == 0) ? "" : p1->code, p2->pop->opstring, (p2->code == 0) ? "" : p2->code); return 0; } #endif /* !ASWAS */ return(0); . . . -- Bug/s is a trademark of Volkswagen/Warner Brothers. C is a trademark of Jack Benny/Mel Blanc. -- UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado@seismo.ARPA DEC, VAX, Elsie & Ado are Digital, Borden & Ampex trademarks.