[PATCH] D128364: [InstCombine] Look through more casts when folding memchr and memcmp

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 11:16:34 PDT 2022


spatel added a comment.

In D128364#3619587 <https://reviews.llvm.org/D128364#3619587>, @msebor wrote:

> I've relaxed the test in rGd515211a0ce1 <https://reviews.llvm.org/rGd515211a0ce1> to avoid exercising the target-dependent behavior.  Please let me know if you see any other issues.

That avoids the test failure, but we still have a host-platform difference that seems unnecessary.

IIUC, the problem is here:
https://github.com/llvm/llvm-project/blob/649439e7aeeb3b30f54297b3c6f7d6549fb2f85a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp#L87

On Linux, errno isn't set for an empty string:
https://godbolt.org/z/Tn5j1o4s6

But on a Mac (I tested locally - not sure if it's possible to do that on godbolt), I get this output:

  Value of errno: 22
  res = 0

Instead of return nullptr on errno, just remove that check? Or return a null constant since anything goes at that point?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128364/new/

https://reviews.llvm.org/D128364



More information about the llvm-commits mailing list