home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / g / bug / 2067 < prev    next >
Encoding:
Text File  |  1992-12-22  |  13.6 KB  |  595 lines

  1. Newsgroups: gnu.g++.bug
  2. Path: sparky!uunet!spool.mu.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!cygnus.com!mrs
  3. From: mrs@cygnus.com (Mike Stump)
  4. Subject: Re:  GCC 2.1 - Bad code for 68k with g++ persists.
  5. Message-ID: <9212212203.AA15653@cygnus.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Mon, 21 Dec 1992 22:03:24 GMT
  10. Approved: bug-g++@prep.ai.mit.edu
  11. Lines: 582
  12.  
  13. This problem has been fixed, and should not exist in the next release of gcc.
  14.  
  15. > Message-Id: <9204030609.AA16331@raisin-nut>
  16. > To: bug-gcc@prep.ai.mit.edu
  17. > Cc: bst%tt@cam.org
  18. > Date: Thu, 02 Apr 92 21:18:28 -0500
  19. > From: Brent Townshend <bst%tt@cam.org>
  20.  
  21. > I just checked out gcc 2.1 to see if the following bug
  22. > is fixed and discovered that it is still present.  Since
  23. > I did not see my previous bug report on my news feed of
  24. > gnu.gcc.bug I am reposting this in case the original bug
  25. > report was lost.
  26. > -Brent
  27.  
  28. > ------- Forwarded Message
  29.  
  30. > Date: Thu, 5 Mar 92 16:22:18 EST
  31. > From: bst (Brent Townshend)
  32. > Message-Id: <9203052122.AA13825@tt.UUCP>
  33. > To: bug-gcc@prep.ai.mit.edu
  34. > Cc: bst
  35.  
  36. > Using g++ 2.0 (built from gcc 2.0),
  37. > I just hit a case of some bad code generated for a 68k target
  38. > using a Sparc host.  The result is that the code tries to 
  39. > access a 32bit word on an odd-byte boundary.   The situation
  40. > that causes the bug seems complicated -- the example following
  41. > is about the smallest I could pare it down to without undue 
  42. > effort.  The bad assembler output below is marked with BAD.
  43.  
  44.  
  45. > Configuration:
  46. > #!/bin/sh
  47. > # GCC was configured as follows:
  48. > ../../gcc/gcc-2.00/configure --host=sun4 --target=sun3
  49. > The sun3.h file was editted to change TARGET to 0 from 7
  50. > for compilation to a 68000 with no floating point.  This
  51. > configuration was then built and installed as tct68. Some
  52. > of the link specs were also changed, but I doubt that will
  53. > affect the results.  (If it does I will send more info).
  54.  
  55. > Host:
  56. > Sparc 1+ SunOS 4.1
  57.  
  58. > Command line:
  59. > g++ -S -btct68 -O bug.c
  60.  
  61. > Source File (bug.c)
  62. > - ----------------------------------
  63. > typedef unsigned char byte;
  64. > typedef unsigned short word;
  65. > typedef unsigned int u_int;
  66. > typedef byte boolean;
  67. > extern void debug(int level,const char *fmt,...);
  68. > extern void debug(const char *t_name,int level,const char *fmt,...);
  69. > struct Status {
  70. >     enum StatCodes {
  71. >     Good = 0x00,
  72. >     CheckCondition = 0x02,
  73. >     ConditionMet = 0x04,
  74. >     Busy = 0x08,
  75. >     Intermediate = 0x10,
  76. >     IntermediateConditionMet = 0x14,
  77. >     ReservationConflict = 0x18,
  78. >     CommandTerminated = 0x22,
  79. >     QueueFull = 0x28,
  80. >     } code;
  81. >     Status()
  82. >     { code = Good; }
  83. >     Status(StatCodes c)
  84. >     { code = c; }
  85. > };
  86. > class SCSICommand;
  87. > class SCSI;
  88. > class SCSIUnit {
  89. >     Status stat;
  90. >     byte reservedBy;      
  91. >     byte reservedFor;     
  92. >     int init;             
  93. >     byte unitAttention;   
  94. >   protected:
  95. >     static const unsigned int MaxSCSIHold;   
  96. >     void MainLoop();
  97. >     virtual Status ChangeDefinition(boolean save, byte defParam,
  98. >                     byte paramDataLength);
  99. >     virtual Status Compare(boolean pad, u_int paramListLength);
  100. >     virtual Status Copy(boolean pad, u_int paramListLength);
  101. >     virtual Status CopyAndVerify(boolean pad, boolean byteCheck,
  102. >                  u_int paramListLength);
  103. >     virtual Status Inquiry(boolean EPVD, byte pageCode, byte allocLength);
  104. >     virtual Status LogSelect(boolean savePages, boolean paramCodeReset,
  105. >                  byte pageControl,word allocLength);
  106. >     virtual Status LogSense(boolean savePages, boolean paramPtrControl,
  107. >                 byte pageControl, byte pageCode,word paramPointer,
  108. >                 word allocLength);
  109. >     virtual Status ModeSelect(boolean tenByte, boolean pageFormat,
  110. >                   boolean savePages,word paramListLength);
  111. >     virtual Status ModeSense(boolean tenByte, boolean disableBlockDesc,
  112. >                  byte pageControl,byte pageCode,word allocLength);
  113. >     virtual Status ReadBuffer(byte mode, byte bufferID, u_int bufferOffset,
  114. >                   u_int allocLength);
  115. >     virtual Status ReceiveDiagnosticResults(word allocLength);
  116. >     virtual Status RequestSense(word allocLength);
  117. >     virtual Status SendDiagnostic(boolean pageFormat, boolean selfTest,
  118. >                   boolean deviceOffLine, boolean unitOffLine,
  119. >                   word paramListLength);
  120. >     virtual Status TestUnitReady();
  121. >     virtual Status WriteBuffer(byte mode, byte bufferID, u_int bufferOffset,
  122. >                   u_int paramListLength);
  123. >     byte mediumType;
  124. >     byte deviceSpecificParameter;
  125. >     u_int bdLength;
  126. >     u_int modeDataLength;
  127. >     byte *modeData;
  128. >     int BlockSize() const;
  129. >     Status Unimplemented(const char *s);
  130. >     int Read(byte *data, int nbytes);
  131. >     int Write(const byte *data, int nbytes);
  132. >   public:
  133. >     SCSIUnit();
  134. >     virtual ~SCSIUnit();
  135. >     virtual Status Execute(const SCSICommand &cmd);
  136. > };
  137. > class SCSICommand {
  138. >   public:
  139. >     enum OpCodeType {
  140. >     Inquiry = 0x12,
  141. >     ModeSelect6 = 0x15,
  142. >     ModeSense6 = 0x1a,
  143. >     RequestSense = 0x03,
  144. >     TestUnitReady = 0x00,
  145. >     ChangeDefinition = 0x40,
  146. >     Compare = 0x39,
  147. >     Copy = 0x18,
  148. >     CopyAndVerify = 0x3a,
  149. >     LogSelect = 0x4c,
  150. >     LogSense = 0x4d,
  151. >     ModeSelect10 = 0x55,
  152. >     ModeSense10 = 0x5a,
  153. >     ReadBuffer = 0x3c,
  154. >     ReceiveDiagnosticResults = 0x1c,
  155. >     SendDiagnostic = 0x1d,
  156. >     WriteBuffer = 0x3b,
  157. >     Erase = 0x19,
  158. >     Read = 0x08,
  159. >     ReadBlockLimits = 0x05,
  160. >     ReleaseUnit = 0x17,
  161. >     ReserveUnit = 0x16,
  162. >     Rewind = 0x01,
  163. >     Space = 0x11,
  164. >     Write = 0x0a,
  165. >     WriteFilemarks = 0x10,
  166. >     LoadUnload = 0x1b,
  167. >     Locate = 0x2b,
  168. >     PreventAllowMediumRemoval = 0x1e,
  169. >     ReadPosition = 0x34,
  170. >     ReadReverse = 0x0f,
  171. >     RecoverBufferedData = 0x14,
  172. >     Verify = 0x13,
  173. >     RequestBlockAddress = 0x02,
  174. >     SeekBlock = 0x0c,
  175. >     };
  176. >   private:
  177. >     byte data[12];
  178. >   public:
  179. >     OpCodeType OpCode() const { return (OpCodeType)data[0]; }
  180. >     const byte &GetByte(int i) const { return data[i]; }
  181. >     word GetWord(int i) const { return data[i]<<8|data[i+1]; }
  182. >     u_int GetUInt(int msb, int lsb) const;
  183. >     boolean GetBit(int bytenum, int bitnum) const
  184. >     { return (GetByte(bytenum)>>bitnum)&0x1; }
  185. > };
  186. > Status SCSIUnit::Execute(const SCSICommand &cmd)
  187. > {
  188. >     switch (cmd.OpCode()) {
  189. >       case SCSICommand::Inquiry:
  190. >     return Inquiry(cmd.GetBit(1,0),cmd.GetByte(2),cmd.GetByte(4));
  191. >       case SCSICommand::ModeSelect6:
  192. >       case SCSICommand::ModeSelect10:
  193. >     boolean tenByte = (cmd.OpCode() == SCSICommand::ModeSelect10);
  194. >     boolean pageFormat = cmd.GetBit(1,4);
  195. >     boolean savePages = cmd.GetBit(1,0);
  196. >     word paramListLength;
  197. >     if (tenByte)
  198. >         paramListLength = cmd.GetUInt(7,8);
  199. >     else
  200. >         paramListLength = cmd.GetByte(4);
  201. >     debug(1,"ModeSelect(tenByte=%c,pageFormat=%c,savePages=%c,paramL
  202. > istLen=%d)\n",
  203. >           ((tenByte)?'T':'F') ,((pageFormat)?'T':'F')
  204. > ,((savePages)?'T':'F') ,paramListLength);
  205. >     return ModeSelect(tenByte, pageFormat, savePages, paramListLength);
  206. >       case SCSICommand::ModeSense6:
  207. >       case SCSICommand::ModeSense10:
  208. >     tenByte = (cmd.OpCode() == SCSICommand::ModeSense10);
  209. >     byte PC = cmd.GetByte(2)>>6;
  210. >     word allocLength;
  211. >     if (tenByte)
  212. >         allocLength = cmd.GetUInt(7,8);
  213. >     else
  214. >         allocLength = cmd.GetByte(4);
  215. >     boolean DBD = cmd.GetBit(1,3);
  216. >     byte pageCode = cmd.GetByte(2)&0x3f;
  217. >     debug(1,"ModeSense(tenByte=%c,DBD=%c,PC=%d,page=%d,allocLen=%d)\n",
  218. >           ((tenByte)?'T':'F') ,((DBD)?'T':'F') ,PC,pageCode,allocLength);
  219. >     return ModeSense(tenByte, DBD, PC, pageCode, allocLength);
  220. >       case SCSICommand::SendDiagnostic:
  221. >     debug(1,"SendDiagnostice(pageFormat=%c,selfTest=%c,deviceOffLine
  222. > =%c,unitOffLine=%c,paramListLength=%d)\n",
  223. >           ((cmd.GetBit(1,4))?'T':'F') ,((cmd.GetBit(1,2))?'T':'F')
  224. > ,((cmd.GetBit(1,1))?'T':'F') ,
  225. >           ((cmd.GetBit(1,0))?'T':'F') ,cmd.GetWord(3));
  226. >     return SendDiagnostic(cmd.GetBit(1,4),cmd.GetBit(1,2),cmd.GetBit(1,1),
  227. >                   cmd.GetBit(1,0),cmd.GetWord(3));
  228. >       case SCSICommand::WriteBuffer:
  229. >     debug(1,"WriteBuffer(mode=%d,bufferID=%d,bufferOffset=%d,paramLen=%d)\n",
  230. >           cmd.GetByte(1)&0x7,cmd.GetByte(2),cmd.GetUInt(3,5),cmd.GetUInt(6,8));
  231. >     return
  232. > WriteBuffer(cmd.GetByte(1)&0x7,cmd.GetByte(2),cmd.GetUInt(3,5),cmd.GetUInt(6,8));
  233. >       default:
  234. >     char buf[10];
  235. >     return Unimplemented(buf);
  236. >     }
  237. > }
  238. > Assembler output (bug.s)
  239. > - ----------------------------------
  240. > #NO_APP
  241. > gcc2_compiled.:
  242. > .text
  243. > LC0:
  244. >     .ascii
  245. > "ModeSelect(tenByte=%c,pageFormat=%c,savePages=%c,paramListLen=%d)\12\0"
  246. > LC1:
  247. >     .ascii "ModeSense(tenByte=%c,DBD=%c,PC=%d,page=%d,allocLen=%d)\12\0"
  248. > LC2:
  249. >     .ascii
  250. > "SendDiagnostice(pageFormat=%c,selfTest=%c,deviceOffLine=%c,unitOffLine=
  251. > %c,paramListLength=%d)\12\0"
  252. > LC3:
  253. >     .ascii "WriteBuffer(mode=%d,bufferID=%d,bufferOffset=%d,paramLen=%d)\12\0"
  254. >     .even
  255. > .globl _Execute__8SCSIUnitRC11SCSICommand
  256. > _Execute__8SCSIUnitRC11SCSICommand:
  257. >     link a6,#-28
  258. >     moveml #0x3f3c,sp@-
  259. >     movel a1,d6
  260. >     movel a6@(12),a5
  261. >     movel a6@(8),a3
  262. >     movel a3@(26),a6@(-14)
  263. >     clrl d0
  264. >     moveb a5@,d0
  265. >     moveq #29,d7
  266. >     cmpl d0,d7
  267. >     jeq L47
  268. >     jlt L82
  269. >     moveq #21,d4
  270. >     cmpl d0,d4
  271. >     jeq L18
  272. >     jlt L83
  273. >     moveq #18,d7
  274. >     cmpl d0,d7
  275. >     jeq L12
  276. >     jra L79
  277. > L83:
  278. >     moveq #26,d4
  279. >     cmpl d0,d4
  280. >     jeq L34
  281. >     jra L79
  282. > L82:
  283. >     moveq #85,d7
  284. >     cmpl d0,d7
  285. >     jeq L18
  286. >     jlt L84
  287. >     moveq #59,d4
  288. >     cmpl d0,d4
  289. >     jeq L74
  290. >     jra L79
  291. > L84:
  292. >     moveq #90,d7
  293. >     cmpl d0,d7
  294. >     jeq L34
  295. >     jra L79
  296. > L12:
  297. >     moveb a5@(4),d4
  298. >     clrl sp@-
  299. >     moveb d4,sp@(3)
  300. >     moveb a5@(2),d7
  301. >     clrl sp@-
  302. >     moveb d7,sp@(3)
  303. >     moveb a5@(1),d4
  304. >     moveq #1,d7
  305. >     andl d7,d4
  306. >     movel d4,sp@-
  307. >     movel a6@(-14),a3
  308. >     movew a3@(40),a0
  309. >     movel a6@(8),d7
  310. >     pea a0@(d7:l)
  311. >     movel d6,a1
  312. >     movel a3@(44),a0
  313. >     jbsr a0@
  314. >     jra L10
  315. > L18:
  316. >     moveq #0,d0
  317. >     movel a5,a0
  318. >     moveb a0@+,d0
  319. >     moveq #85,d4
  320. >     cmpl d0,d4
  321. >     seq d3
  322. >     negb d3
  323. >     clrl d0
  324. >     moveb a0@,d0
  325. >     movel d0,d1
  326. >     asrl #4,d1
  327. >     moveq #1,d5
  328. >     andl d1,d5
  329. >     moveq #1,d7
  330. >     andl d0,d7
  331. >     moveb d7,a6@(-19)
  332. >     tstb d3
  333. >     jeq L24
  334. >     pea 8:w
  335. >     pea 7:w
  336. >     movel a5,sp@-
  337. >     jbsr _GetUInt__C11SCSICommandii
  338. >     movew d0,d2
  339. >     addw #12,sp
  340. >     jra L25
  341. > L24:
  342. >     clrw d2
  343. >     moveb a5@(4),d2
  344. > L25:
  345. >     movew d2,sp@-
  346. >     clrw sp@-
  347. >     moveq #70,d0
  348. >     tstb a6@(-19)
  349. >     jeq L27
  350. >     moveq #84,d0
  351. > L27:
  352. >     movel d0,sp@-
  353. >     moveq #70,d0
  354. >     tstb d5
  355. >     jeq L29
  356. >     moveq #84,d0
  357. > L29:
  358. >     movel d0,sp@-
  359. >     moveq #70,d0
  360. >     tstb d3
  361. >     jeq L31
  362. >     moveq #84,d0
  363. > L31:
  364. >     movel d0,sp@-
  365. >     pea LC0
  366. >     pea 1:w
  367. >     jbsr _debug__FiPCce
  368. >     movew d2,sp@-
  369. >     clrw sp@-
  370. >     moveq #1,d4
  371. >     andl a6@(-22),d4
  372. >     movel d4,sp@-
  373. >     moveq #1,d7
  374. >     andl d5,d7
  375. >     movel d7,sp@-
  376. >     clrl sp@-
  377. >     moveb d3,sp@(3)
  378. >     movel a6@(-14),a3
  379. >     movew a3@(64),a0
  380. >     movel a6@(8),d7
  381. >     pea a0@(d7:l)
  382. >     movel d6,a1
  383. >     movel a3@(68),a0
  384. >     jbsr a0@
  385. >     jra L10
  386. > L34:
  387. >     cmpb #90,a5@
  388. >     seq d3
  389. >     negb d3
  390. >     moveb a5@(2),d0
  391. >     lsrb #6,d0
  392. >     moveb d0,a6@(-15)
  393. >     tstb d3
  394. >     jeq L37
  395. >     pea 8:w
  396. >     pea 7:w
  397. >     movel a5,sp@-
  398. >     jbsr _GetUInt__C11SCSICommandii
  399. >     movew d0,d2
  400. >     addw #12,sp
  401. >     jra L38
  402. > L37:
  403. >     clrw d2
  404. >     moveb a5@(4),d2
  405. > L38:
  406. >     moveb a5@(1),d0
  407. >     lsrl #3,d0
  408. >     moveq #1,d5
  409. >     andl d0,d5
  410. >     moveb a5@(2),d4
  411. >     andb #63,d4
  412. >     moveb d4,a6@(-16)
  413. >     movew d2,sp@-
  414. >     clrw sp@-
  415. >     moveq #63,d7
  416. >     andl d4,d7
  417. >     movel d7,sp@-
  418. >     moveq #3,d4
  419. >     andl a6@(-18),d4
  420. >     movel d4,sp@-
  421. >     moveq #70,d0
  422. >     tstb d5
  423. >     jeq L43
  424. >     moveq #84,d0
  425. > L43:
  426. >     movel d0,sp@-
  427. >     moveq #70,d0
  428. >     tstb d3
  429. >     jeq L45
  430. >     moveq #84,d0
  431. > L45:
  432. >     movel d0,sp@-
  433. >     pea LC1
  434. >     pea 1:w
  435. >     jbsr _debug__FiPCce
  436. >     movew d2,sp@-
  437. >     clrw sp@-
  438. >     moveq #63,d7
  439. >     andl a6@(-19),d7        <<<<<<<<<< BAD alignment
  440. >     movel d7,sp@-
  441. >     moveq #3,d4
  442. >     andl a6@(-18),d4
  443. >     movel d4,sp@-
  444. >     moveq #1,d7
  445. >     andl d5,d7
  446. >     movel d7,sp@-
  447. >     clrl sp@-
  448. >     moveb d3,sp@(3)
  449. >     movel a6@(-14),a3
  450. >     movew a3@(72),a0
  451. >     movel a6@(8),d7
  452. >     pea a0@(d7:l)
  453. >     movel d6,a1
  454. >     movel a3@(76),a0
  455. >     jbsr a0@
  456. >     jra L10
  457. > L47:
  458. >     clrl d0
  459. >     moveb a5@(3),d0
  460. >     asll #8,d0
  461. >     clrl d1
  462. >     moveb a5@(4),d1
  463. >     orl d1,d0
  464. >     movel d0,sp@-
  465. >     moveb a5@(1),d0
  466. >     moveq #1,d4
  467. >     andl d4,d0
  468. >     moveq #70,d1
  469. >     tstb d0
  470. >     jeq L49
  471. >     moveq #84,d1
  472. > L49:
  473. >     movel d1,sp@-
  474. >     moveq #70,d0
  475. >     btst #1,a5@(1)
  476. >     jeq L53
  477. >     moveq #84,d0
  478. > L53:
  479. >     movel d0,sp@-
  480. >     moveq #70,d0
  481. >     btst #2,a5@(1)
  482. >     jeq L57
  483. >     moveq #84,d0
  484. > L57:
  485. >     movel d0,sp@-
  486. >     moveq #70,d0
  487. >     btst #4,a5@(1)
  488. >     jeq L61
  489. >     moveq #84,d0
  490. > L61:
  491. >     movel d0,sp@-
  492. >     pea LC2
  493. >     pea 1:w
  494. >     jbsr _debug__FiPCce
  495. >     addw #28,sp
  496. >     clrl d1
  497. >     moveb a5@(3),d1
  498. >     asll #8,d1
  499. >     clrl d0
  500. >     moveb a5@(4),d0
  501. >     orl d0,d1
  502. >     movel d1,sp@-
  503. >     clrl d0
  504. >     moveb a5@(1),d0
  505. >     moveq #1,d7
  506. >     andl d0,d7
  507. >     movel d7,sp@-
  508. >     movel d0,d1
  509. >     asrl #1,d1
  510. >     moveq #1,d4
  511. >     andl d4,d1
  512. >     movel d1,sp@-
  513. >     movel d0,d1
  514. >     asrl #2,d1
  515. >     andl d4,d1
  516. >     movel d1,sp@-
  517. >     asrl #4,d0
  518. >     andl d4,d0
  519. >     movel d0,sp@-
  520. >     movel a6@(-14),a3
  521. >     movew a3@(104),a0
  522. >     movel a6@(8),d7
  523. >     pea a0@(d7:l)
  524. >     movel d6,a1
  525. >     movel a3@(108),a0
  526. >     jbsr a0@
  527. >     jra L10
  528. > L74:
  529. >     pea 8:w
  530. >     pea 6:w
  531. >     movel a5,sp@-
  532. >     lea _GetUInt__C11SCSICommandii,a2
  533. >     jbsr a2@
  534. >     movel d0,sp@-
  535. >     pea 5:w
  536. >     pea 3:w
  537. >     movel a5,sp@-
  538. >     jbsr a2@
  539. >     addqw #8,sp
  540. >     movel d0,sp@
  541. >     lea a5@(2),a4
  542. >     moveb a4@,d4
  543. >     clrl sp@-
  544. >     moveb d4,sp@(3)
  545. >     lea a5@(1),a3
  546. >     moveb a3@,d0
  547. >     andb #7,d0
  548. >     moveq #7,d7
  549. >     andl d0,d7
  550. >     movel d7,sp@-
  551. >     pea LC3
  552. >     pea 1:w
  553. >     jbsr _debug__FiPCce
  554. >     addw #32,sp
  555. >     movel #8,sp@
  556. >     pea 6:w
  557. >     movel a5,sp@-
  558. >     jbsr a2@
  559. >     movel d0,sp@-
  560. >     pea 5:w
  561. >     pea 3:w
  562. >     movel a5,sp@-
  563. >     jbsr a2@
  564. >     addqw #8,sp
  565. >     movel d0,sp@
  566. >     moveb a4@,d4
  567. >     clrl sp@-
  568. >     moveb d4,sp@(3)
  569. >     moveb a3@,d0
  570. >     andb #7,d0
  571. >     moveq #7,d7
  572. >     andl d0,d7
  573. >     movel d7,sp@-
  574. >     movel a6@(-14),a3
  575. >     movew a3@(120),a0
  576. >     movel a6@(8),d7
  577. >     pea a0@(d7:l)
  578. >     movel d6,a1
  579. >     movel a3@(124),a0
  580. >     jbsr a0@
  581. >     jra L10
  582. > L79:
  583. >     pea a6@(-10)
  584. >     movel a6@(8),sp@-
  585. >     movel d6,a1
  586. >     jbsr _Unimplemented__8SCSIUnitPCc
  587. > L10:
  588. >     movel d6,d0
  589. >     moveml a6@(-68),#0x3cfc
  590. >     unlk a6
  591. >     rts
  592.  
  593. > ------- End of Forwarded Message
  594.  
  595.