[PATCH] Fixing a corner-case bug in lib call optimization

Eli Friedman eli.friedman at gmail.com
Tue Aug 13 14:35:08 PDT 2013


On Tue, Aug 13, 2013 at 2:03 PM, Gao, Yunzhong <
yunzhong_gao at playstation.sony.com> wrote:

> Hi Nick,
> Thanks for reviewing the patch.
> I will change the type conversion to "unsigned char" instead; that should
> make
> the result deterministic.
> I feel that this is probably still not an ideal solution because the host
> machine
> might have a different size for "char" type than the target machine, but
> in the
> llvm backend I did not find a way to extract the size of target "char"
> type. I
> would guess that machines with non-8-bit bytes are rare nowadays? Since
> the patch is only intended for a corner-case comparing a value with zero,
> it
> might suffice using a cast to "unsigned char" or even "(value & 255)".
> What do you think?
>  <http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>

Assuming char is 8 bits is probably good enough.   You could also extract
the relevant type out of the function signature; the first argument to
strchr is a char*.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130813/69144b57/attachment.html>


More information about the llvm-commits mailing list