<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/77064>77064</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SimplifyLibCalls] Calling convention assertion fails
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:crash,
llvm:instcombine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
nikic
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nikic
</td>
</tr>
</table>
<pre>
```llvm
; RUN: opt -S -passes=instcombine
define void @main(ptr %ptr) {
%opendir = call fastcc ptr @opendir(ptr %ptr)
%memset = call ptr @__memset_chk(ptr %opendir, i32 0, i64 596, i64 -1)
ret void
}
declare ptr @__memset_chk(ptr, i32, i64, i64)
declare fastcc ptr @opendir(ptr)
```
> opt: /home/npopov/repos/llvm-project/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:3488: Value *llvm::LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *, IRBuilderBase &): Assertion `(ignoreCallingConv(Func) || TargetLibraryInfoImpl::isCallingConvCCompatible(CI)) && "Optimizing string/memory libcall would change the calling convention"' failed.
Encountered when building openjpeg2.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE2P2zYQ_TXUhViDpr4POthyBBhIWyCb9LqgpJE0CUUSJOVg--sLStq1u20DGCA95HvDN_M0wjkcFUBF0jPhXOEP7AjnJL1EYvGTttUailrdv1YkY9tPyttM2IWwE4nP9Mu330l8otp4-vRMn4xwDhyJL6ic7_TcooLtcg8DKqA3jT0lCZsFKsIL4y0lPDXeEl5Skp-3yyGmDageLSXxhXZCSjoI57uOrpCE7ccfOXZ8CMwwO_B3_A58edkOXrrpxx39TldTjDll6yZLaFpmb9un4wO_Bb9q2SuRX_bNrrWTwsL_Z9zT7MzvS_lfJL-QfUe8NeeRgMSfQl9CewhvJj0D4Y0y2ugb4Y0Fox3hTWjnk7H6O3R-_xsWbAlvvlqh3KDtHC5-8yjD-oyzkTi8fsa2FlK6Q2cMiU9xUhQh1Z9CLkAJP61M8YnEp_3mDkSwW1gbjzP-Bc_eohp_g1nbN1LCi7BclfOBKhTo-uW8oOzBnoUL_FkQH5_oyTmwHrWiQT4vcFTaQkCjGmutboQXzaK6zV81yWv6VdgR_GdsrbCvVzXo62zk9iZ0D8i61rMRHlsJ4UHXkDGwhNwZJZz_sSlANVK3iiC8mVcdVGK7mu6nXmRPu0moEaifYLViAHRa3UCFh4dPjud0ECihPzx28JPq9KI8WOjpzwkUbUMJAjrY4LuBkR-ivor7Mi5FBNUxZ0mSZGWcRlNVxEVeDDwphiJPecmLok37gRXZcWgZJCLCijOesCNLWcmLND20JRvytEuTTAyCd4wkDGaB8hBaedB2jNC5Bao8Z1kSSdGCdPvs2JvdWeGmVU99Dz6Ogm262Gp1XbuMjiRMovPunsOjl-tI-mg0kl5o_a_qUfFugFBBFy1WVpP3xoWO8obwZkQ_Le2h0_ODwf9p-1VYcPeq7e8AAAD___oilqE">