The discussion in PR #56463 points out that LLVM might abort when trying to simplify a call to a known library function when it's declared with an unexpected/incompatible signature. The root cause of the problems is inadequate compatibility checking by TargetLibraryInfoImpl::isValidProtoForLibFunc where only some arguments are subject to having their types checked, and the checks for the numbers of arguments are overly permissive, allowing for calls with either fewer or more arguments. This is a recurring problem with reports of similar crashes in PR #50836, #50180, #50850, #50885, 50846, and possibly others.
This change tightens up the checking for a number of library functions, although more still remain.
Does the precessor allow writing something like defined(TLI_DEFINE_ENUM) + defined(TLI_DEFINE_STRING) + defined(TLI_DEFINE_SIG) == 1? Might be a clearer way to express this...