If a wrapper around one of the mem* stdlib functions bitcasts the returned
pointer value before returning it (e.g. to a wchar_t*), LLVM does not emit a
tail call.
Add a check for this scenario so that we emit a tail call.
Differential D59078
Fix missing memcpy, memmove and memset tail calls sanwou01 on Mar 7 2019, 1:45 AM. Authored by
Details If a wrapper around one of the mem* stdlib functions bitcasts the returned Add a check for this scenario so that we emit a tail call.
Diff Detail
Event TimelineComment Actions Updated the summary to properly reflect the issue and the solution. Added a test case. Comment Actions Hi, I'd like to take over this change to get it committed. There is a crash lurking when llvm::returnTypeIsEligibleForTailCall is called with a function that takes no arguments, so I'd like to make some changes before committing. Thanks. Comment Actions Yeah. LGTM. Thanks for carrying this forward!
|
I don't think these two asserts are required if you wanted to leave them out. It's pretty much implied from the signature that the two values will not be null.
If you do want to keep them in, run clang format and add a message to the asserts. Something like:
assert(a && b && "Expected non-null inputs!");