µTasker Forum
September 09, 2010, 04:49:44 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: January 2010: uTasker utFAT version released for M522XX, SAM7X, LM3SXXXX, LPC2XXX and AVR32 - see utFAT board for full details!
Note that Internet Explorer 8 doesn't work with the forum (unless compatibility view is selected); please use Firefox or Chrome (or other well behaved browsers) as alternative!
 
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Codewarrior 7.1.2 optimisation problem  (Read 1155 times)
mark
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1912



View Profile WWW
« on: August 25, 2009, 10:08:45 am »

Hi All

Below is a copy of a service request sent to Freescale concerning a problem which appeared with the CW 7.1.2 version.
See also the following for a workaround: http://www.utasker.com/forum/index.php?topic=657.0    



1) The TCP stack in the uTasker project is broken when using CW7.1.2 patch and level 4 optimization). No problems with CW7.1.1 patch.
2) In TCP reception code the FIN flag is not recognized at a critical location. At other code locations work normally.
3) Eg correct case: if (rx_tcp_packet->usHeaderLengthAndFlags & TCP_FLAG_RESET) here the assembler shows the variable being collected from 24 bytes offset from SP (corresponds with the struct) lea 24(a7),d1 - then bit test on d1
4) Eg. the incorrect case which causes the project to fail: if (rx_tcp_packet->usHeaderLengthAndFlags & TCP_FLAG_FIN) The assembler code does a bit check of a location 6 bytes offset to where the value really is - btst #0,30(a7)
5) This value is then never true and no TCP connections can be closed normally.
6) The problem can be reproduced by all uTasker project users (field problem reports for users moving from CW 7.1.1 to CW7.1.2). The problem disappears when optimization is removed.
7) Workaround: By copying the value where it is initialized (where it is correctly placed in the struct) to a register and using the register value for the compare solves the problem in the project case.
8 ) Complete project is available for download for test on M52235 EVB where it works normally with CW7.1.1 and earlier but fails with CW7.1.2. Please request if required - the error is also easily visible in the disassembly. Regards Mark Butcher



Regards

Mark
Logged
alager
Jr. Member
**
Offline Offline

Posts: 68


View Profile
« Reply #1 on: November 30, 2009, 07:59:51 pm »

Mark,

Has Freescale updated you on this?  I noticed that the patches section shows 7.1.2a, but the actual download filename still says 7.1.2.  So I wasn't sure if I should stay away from 7.1.2 for now, or what.

Thanks,
Aaron
Logged
mark
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1912



View Profile WWW
« Reply #2 on: November 30, 2009, 08:08:33 pm »

Hi Aaron

I didn't get an update so am not sure whether there is a newer version with any fixes or not.

Since the problem is very reproducible it should be quite easy to test whether any particular compiler version suffers from it or not.

Regards

Mark
Logged
alager
Jr. Member
**
Offline Offline

Posts: 68


View Profile
« Reply #3 on: February 23, 2010, 05:39:19 pm »

Has anyone tried out the new code warrior 7.2?  Is it good to use, or should it be avoided? Huh

Aaron
Logged
aersek
Newbie
*
Offline Offline

Posts: 11


View Profile
« Reply #4 on: February 23, 2010, 07:17:36 pm »

I didn't tried Codewarrior 7.2 but I have found few posts on freescale forum about bug and problems with compiling in CW 7.2, so for now is best to still use 7.1 version. On freescale web can be downloaded beta version of Codewarrior 10.0, it is completely new concept, it is Eclipse based IDE, maybe there are solved compile optimizations problems.

Regards

Andrija
Logged
alager
Jr. Member
**
Offline Offline

Posts: 68


View Profile
« Reply #5 on: March 16, 2010, 10:01:24 pm »

It looks like it's just a trade off of one set of compiler problems for another.  Going from 7.1.1a to 7.2.
7.2 did shave off 4k, but in quick tests it had issues with some of the saved parameters.

But 7.1.1a has it's own issues.  Below, in this function I had to move a text string into a buffer to send it, otherwise CW would optimize it out.  I even tried turning off optimizations, to no avail.
Oh well.
Code:
static void fnDNSListner(unsigned char ucEvent, unsigned char *ptrIP){
CHAR cBuf[16];
    switch (ucEvent) {
case DNS_EVENT_SUCCESS:
uStrcpy(cBuf, "DNS answer: ");
fnDebugMsg(cBuf);
//fnDebugMsg("DNS answer: ");  //code warror optimizes this line away
fnIPStr(ptrIP, cBuf);
fnDebugMsg(cBuf);
fnDebugMsg("\r\n");
//uMemcpy(ip_sockets.ip, ptrIP, IPV4_LENGTH);                      // save the IP address which has just been resolved
break;
default:                                                             // DNS error message
break;
    }
}

Aaron
Logged
danh
Newbie
*
Offline Offline

Posts: 28


View Profile
« Reply #6 on: March 26, 2010, 02:33:18 am »

I just noticed some other distressing behavior related to Codewarrior 7.1.2.  Note the simple 'if' expression on the third line here. Using CW 6.3 and 7.1 (as well as the simulator), the expression evaluates correctly. But under CW 7.1.2, it always evaluates to false. Using 'and' instead of 'or' in the expression works fine. This problem happens with any level of optimization other than none.

Code:
if(!uStrncasecmp(p, "z1", 2)) {
   type = *(p+1) - 0x30;
   if((type == 1) || (type == 2))
       uPrintf("(%d == 1) || (%d == 2) is true\r\n", type, type);
   else
       uPrintf("(%d == 1) || (%d == 2) is false\r\n", type, type);
   if((type >= 1) && (type <= 2))
       uPrintf("(%d >= 1) && (%d <= 2) is true\r\n", type, type);
   else
       uPrintf("(%d >= 1) || (%d <= 2) is false\r\n", type, type);
 }

Simulator output:
(1 == 1) || (1 == 2) is true
(1 >= 1) && (1 <= 2) is true


Target output:
(1 == 1) || (1 == 2) is false
(1 >= 1) && (1 <= 2) is true
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Copyright © 2010 utasker.com. Webdesign and Hosting by e-future.ch 2010
Valid XHTML 1.0! Valid CSS!
Page created in 0.084 seconds with 19 queries.