HI,
Could a gatekeeper review the attached patch for a compiler assertion
in the EBO phase of CG when -O1 is given?
To see the assertion, DBG build compiler should be used.

Bug description:
----------------

test case:
#pragma pack (2)

struct S4
{
  short a;
  short b : 11;
  int e : 18;
};
#pragma pack (0)

void test_4(void)
{
    struct S4 s;

    s.e = -6619;
    vfy_S4(&s);
}

When the above test case is compiled with the following command,
$ opencc min.c -c -O1

the following assertion is hit:
### Gen_Literal_TN: 4-byte literal 0xf989400000000000 is out-of-range

This assertion failure is within a routine called Gen_Literal_TN,
which is given a size of 4 and a constant value of
-465770717711958016, which is outside the value range of 4 bytes.
Gen_Literal_TN makes a constant TN with the given size and value. The
routine is called from inside Fold_Constant_Expression for the
following OP.
        TN149 :- ldc32 (0xffffffffffffe625) ;
        TN153 :- shli64 TN149 (0x2e) ;
Here, TN149 has -6619 in 4 byte storage and it is shifted to the left
by 46 bits (0x2e). Thus the resulting value of this shift left
operation is outside the range of the 4 byte storage of TN153.

The source code for the above CG IR is as follows.
    struct S4 s;
    s.e = -6619;

And the above CG IR is generated from the following WHIRL.
  I4INTCONST -6619 (0xffffffffffffe625)
I8STBITS 0 <bofst:27 bsize:18> <2,1,s> T<5,.predef_I8,8> {line: 18}

The problem is that the size of TN153 is generated from the kid of
STBITS, which is I4. As can be seen from the above WHIRL IR, the
result type of the kid (I4) does not match the descriptor type of the
parent(I8).

This problem does not occur with -O0 because constant folding is not
invoked. Also, it does not occur with -O2 and above because the WOPT
converts the above WHIRL into the following.
   I8I8LDID 0 <2,1,s> T<5,.predef_I8,8>
   I8INTCONST -6619 (0xffffffffffffe625)
  I8COMPOSE_BITS <bofst:27 bsize:18>
I8STID 0 <2,1,s> T<5,.predef_I8,8> {line: 1/18}
So, this is a problem only at -O1 level.


-- 
yongchong

Attachment: cg.patch
Description: Binary data

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to