<div dir="ltr"><a href="http://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">http://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</a><div><br></div><div>Basically, you can imagine code like this:</div><div><br></div><div>enum CC { cdecl, stdcall, fastcall };</div><div>void callit(CC cc, void *fp) {</div><div>  switch (cc) {</div><div>  case cdecl: ((void(__cdecl*)())fp)(); break;</div><div>  case stdcall: ((void(__stdcall*)())fp)(); break;</div><div>  case fastcall: ((void(__fastcall*)())fp)(); break;<br>  }<br>}</div><div><br></div><div>If we inline 'callit', and discover the true target of fp, those calls become direct, and the verifier should not reject them just because we discovered additional information.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 6, 2017 at 1:32 AM, Juan Manuel Martinez Caamaño 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">Hello,<br>
<br>
If a call instruction and the function being called differ in their call<br>
convention, InstructionCombine will insert a "store true, undef", then<br>
CFGSimplify transforms this store to a llvm.trap() call, and finally,<br>
during execution an InvalidInstruction exception is signaled.<br>
<br>
Is there any reason not to detect the calling convention mismatch in the<br>
verifier ? I would like to add such check.<br>
<br>
<br>
Cheers,<br>
<br>
Juan<br>
<br>
<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>
</blockquote></div><br></div>