Right now, when we encounter a string equality check,
e.g. if (memcmp(a, b, s) == 0), we try to expand to a comparison if s is a
small compile-time constant, and fall back on calling memcmp() else.
This is sub-optimal because memcmp has to compute much more than
equality.
This patch adds a way for the user to specify a memeq library
function using a module flag, e.g.:
!llvm.module.flags = !{..., !123}
!123 = !{i32 1, !"memeq_lib_function", !"user_memeq"}
This function will be called instead of memcmp() when the result of the memcmp
call is only used for equality comparison.
memeq can be made much more efficient than memcmp because equality
compare is trivially parallel while lexicographic ordering has a chain
dependency.