<div dir="ltr"><div>Somewhat related to this patchset, for adding support for specifying address space on functions.</div><div><br></div><div><a href="https://reviews.llvm.org/D37052">https://reviews.llvm.org/D37052</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 17, 2017 at 7:00 AM, Reid Kleckner via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This is an old FAQ that I remember running into 8 years ago: <a href="https://llvm.org/docs/FAQ.html#why-does-instcombine-simplifycfg-turn-a-call-to-a-function-with-a-mismatched-calling-convention-into-unreachable-why-not-make-the-verifier-reject-it" target="_blank">https://llvm.org/docs/<wbr>FAQ.html#why-does-instcombine-<wbr>simplifycfg-turn-a-call-to-a-<wbr>function-with-a-mismatched-<wbr>calling-convention-into-<wbr>unreachable-why-not-make-the-<wbr>verifier-reject-it</a><div><br></div><div>However, I think you are right, we could make CreateCall enforce calling convention match for direct calls, and require callers to manually set the calling convention with setCallingConv if they want the convention to not match.</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 16, 2017 at 12:35 AM, serge guelton via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi llvm-dev,<br>
<br>
Every now and then, when building a direct ``CallInst`` either from IRBuilder<br>
or through ``Create*``, I have a latent bug because the calling<br>
convention (CC) expected by the function is not set on the call, and I need<br>
to manually call ``setCallingConv``.<br>
<br>
Now, from LangRef#calling-conventions,<br>
<br>
    The calling convention of any pair of dynamic caller/callee must<br>
    match, or the behavior of the program is undefined.<br>
<br>
So the behavior is correctly defined, as emphasised by the check in<br>
``InstCombineCalls`` that turns mismatching convention into an ``undef``.<br>
<br>
This is however very error-prone. Maybe we should either:<br>
<br>
- update the API to enforce the CC when building a ``CallInst``<br>
<br>
- update LangRef to state that mismatching CC in static call<br>
  is an error (note that LangRef is unclear about static call, the quote<br>
  only references indirect calls)<br>
<br>
- add an optional setting in the ``CreateCall`` that enforces CC<br>
  (and let it default to yes?)<br>
<br>
Any thoughts on that?<br>
<br>
Serge<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>