Message152717
| Author |
meador.inge |
| Recipients |
ezberch, meador.inge, ned.deily, ronaldoussoren, vstinner |
| Date |
2012年02月06日.01:29:18 |
| SpamBayes Score |
5.935874e-06 |
| Marked as misclassified |
No |
| Message-id |
<1328491761.54.0.522141769908.issue13370@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
So I have debugged the first failure and it has to do with the sign extending of 'signed char' parameters. The first test case basically does this:
_dll = CDLL(_ctypes_test.__file__)
_dll.tf_b.restype = c_byte
_dll.tf_b.argtypes = (c_byte,)
_dll.tf_b(-126)
where 'tf_b' is defined in C code like:
signed char tf_b(signed char c) { return c/3; }
Clang with -O3 generates code for 'tf_b' like:
0x0000000100000ed0 <tf_b+0>: push %rbp
0x0000000100000ed1 <tf_b+1>: mov %rsp,%rbp
0x0000000100000ed4 <tf_b+4>: movslq %edi,%rax
0x0000000100000ed7 <tf_b+7>: imul 0ドルx55555556,%rax,%rax
0x0000000100000ede <tf_b+14>: mov %rax,%rcx
0x0000000100000ee1 <tf_b+17>: shr 0ドルx3f,%rcx
0x0000000100000ee5 <tf_b+21>: shr 0ドルx20,%rax
0x0000000100000ee9 <tf_b+25>: add %ecx,%eax
0x0000000100000eeb <tf_b+27>: movsbl %al,%eax
0x0000000100000eee <tf_b+30>: pop %rbp
0x0000000100000eef <tf_b+31>: retq
See how 'movslq' is used to sign extend the first argument? Since the first argument is a 'signed char', that should be 'movsbq'. I am pretty sure this is a clang bug.
I am going to see if this is fixed in later versions of clang. I will also search the clang tracker to see if this has been reported. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年02月06日 01:29:21 | meador.inge | set | recipients:
+ meador.inge, ronaldoussoren, vstinner, ned.deily, ezberch |
| 2012年02月06日 01:29:21 | meador.inge | set | messageid: <1328491761.54.0.522141769908.issue13370@psf.upfronthosting.co.za> |
| 2012年02月06日 01:29:20 | meador.inge | link | issue13370 messages |
| 2012年02月06日 01:29:18 | meador.inge | create |
|