[cfe-dev] FW: GSL 'make check' failure

Kelly Wilson wilsonkk at shaw.ca
Tue Jul 8 11:38:07 PDT 2008


Hello Eli,

I am using the newest version of LLVM/clang, as of today. The short does
look like it is being promoted...and the 'unsigned short' is promoted to
'signed int' instead of unsigned.

I have attached the diff between the 'signed int' and 'unsigned int'
versions of the test_complex_binary function when using -emit-llvm. I also
attached the complete test_complex_binary function.

This is the gist of the diff file:

< 	%cmp = icmp ult i32 %tmp, 1027		; <i1> [#uses=1]
---
> 	%cmp = icmp slt i32 %tmp, 1027		; <i1> [#uses=1]
29c29
< 	%conv = uitofp i32 %sub to double		; <double> [#uses=1]
---
> 	%conv = sitofp i32 %sub to double		; <double> [#uses=1]


So '(un)signed less than' and '(un)signed int to floating point' are the
only differences.

This function is hard to isolate because of all the macro expansions, so I
tried to set up a small test case yesterday, with no luck. Let me know if
you can make something of the attached information and if not I will try to
isolate something again.

Thanks,
K.Wilson



-----Original Message-----
From: Eli Friedman [mailto:eli.friedman at gmail.com] 
Sent: Tuesday, July 08, 2008 10:20 AM
To: Kelly Wilson
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] FW: GSL 'make check' failure

On Tue, Jul 8, 2008 at 12:15 AM, Kelly Wilson <wilsonkk at shaw.ca> wrote:
> Hello Matthijs,
>
> Actually I just checked and the problem with this bit of code is an
unsigned
> integer value for 'i'.
>
> What I previously failed to show in the code snippet was that 'i' is
> declared as type 'size_t'...which I'm guessing defaults to uint32 in this
> case.

Can you give a reduced testcase, i.e. something that I could actually
compile to reproduce the issue?  If you have trouble reducing it, the
output of clang -E for the whole file would be fine.  I'll try to
figure it out, but having actual code will make it a lot easier.

(That said, this looks a bit similar to a bug I fixed recently; are
you updated to trunk?)

Another thing that might help is a diff between the output of clang
-emit-llvm of the unsigned int version vs the output of clang
-emit-llvm for the int version.  That would help narrow down the
problem.

> Instead of using 'size_t i;' I replaced it with a signed int and things
> worked fine. But if I used an unsigned variable then things blew up. Here
is
> a failure table:
>
> short           pass
> ushort  pass
>
> int             pass
> uint            fail
>
> long            pass
> ulong           fail
>
> long long       pass
> ulong long      fail
>
>
> Unsigned short doesn't blow up???? Hmmmm....

My guess is that's because unsigned short promotes to int.  Although,
it's not obvious to me why signed vs unsigned would result in
different code...

-Eli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.uint
Type: application/octet-stream
Size: 7037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080708/25f75d2c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff
Type: application/octet-stream
Size: 785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080708/25f75d2c/attachment-0001.obj>


More information about the cfe-dev mailing list