How to track down a bad llvm optimization pass

Dan Olson via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Tue Jun 21 23:51:32 PDT 2016


Dan Olson <gorox at concast.net> writes:

> On Tuesday, 21 June 2016 at 19:41:59 UTC, Dan Olson wrote:
>> Hmmm.  I looked at failing code in std.conv.  I think it does a
>> negative shift, which is undefined in C.  It is the opSlice()
>> method.
>
> Or rather with unsigned types, a really big shift, also undefined.

std.conv.toChars() just has a bug and LLVM 3.8 is behaving ok with an
undefined operation.  The unittest for toChars isn't very exhaustive for
opSlice and gets lucky on Intel targets.  LDC with LLVM 3.5 also gets
lucky on the limited unittest but toChars() clearly gives wrong results
with better test case.

Simple fix, following line should not have `- 1`:

https://github.com/ldc-developers/phobos/blob/ldc/std/conv.d#L5700

I fixed locally and std.conv unittest is happy now.  I will run full
test suite on arm to make doubly sure, but I think this will end up as a
phobos bug and PR.
-- 
Dan


More information about the digitalmars-d-ldc mailing list