How to track down a bad llvm optimization pass

Johan Engelen via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Wed Jun 29 08:09:33 PDT 2016


On Wednesday, 29 June 2016 at 08:18:46 UTC, Joakim wrote:
> On Wednesday, 22 June 2016 at 16:06:13 UTC, Dan Olson wrote:
>> Joakim <dlang at joakim.fea.st> writes:
>>> shift.d(5): Error: shift by -4 is outside the range 0..31
>>
>> Agree, should be explored more to understand why that error 
>> message didn't appear in this case.
>
> I looked into this and it appears that dmd doesn't do the 
> static analysis necessary to catch such bugs nor insert the 
> runtime checks that could bail out with an exact error:
>
> https://issues.dlang.org/show_bug.cgi?id=7604
> https://issues.dlang.org/show_bug.cgi?id=4835
>
> Walter says he doesn't want runtime checks for performance 
> reasons (comment 11 in the second linked bug), which is 
> understandable.  I'm not sure we can do anything but be more 
> careful about such bugs in our D code.

This is LDC, not DMD, so for this it doesn't matter what Walter 
says :-)
If you can implement a runtime check (default off) for undefined 
shifts, how is that bad? Clang's -fsanitize flags look great. 
http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

cheers,
   Johan



More information about the digitalmars-d-ldc mailing list