<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 22, 2016, at 8:05 PM, Arnab Das via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Hi All,</div><div class=""><br class=""></div><div class="">During the opt phase the following mismatch is spitted from the verifier.cpp for the llvm-39</div><div class=""><br class=""></div><div class=""><span id="gmail-docs-internal-guid-181a0bdb-15b4-34b1-66a4-ccfefd5e45b8" class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">Fom the llvm-39 run</span></div><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size:13.3333px;font-family:"source code pro";color:rgb(255,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent" class="">Call parameter type does not match function signature</span><span style="font-size: 13.3333px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">!</span></div><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 13.3333px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">i8* getelementptr inbounds ([46 x i8], [46 x i8]* @instrname, i32 0, i32 0)</span></div><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 13.3333px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">i8*  %injectError = call i32 @myReferenceFunc(i32 %11, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @instrname, i32 0, i32 0), i32 -1)</span></div></span></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><span id="gmail-docs-internal-guid-181a0bdb-15b4-34b1-66a4-ccfefd5e45b8" class=""><br class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">As the snippet shows, it is issuing a function signature mismatch error.</span></div><br class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">Below is a corresponding snippet of a run from llvm-38 run</span></div><br class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 13.3333px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">%injectError = call i32 @myReferenceFunc(i32 %4, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @instrname, i32 0, i32 0), i32 -1)</span></div><br class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">In the </span><span style="font-size: 14.6667px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">llvm-39</span><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">, it infers the return to be of type char pointer somehow unlike in </span><span style="font-size: 14.6667px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">llvm-38</span><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">.</span></div></span></div></div></div></blockquote><div><br class=""></div><div>I don’t believe the error you’re quoting indicates anything about the return type.</div><div>Here is the code with the assertion:</div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class="">Assert</span><span style="font-variant-ligatures: no-common-ligatures" class="">(CS.getArgument(i)->getType() == FTy->getParamType(i),</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">           </span><span style="font-variant-ligatures: no-common-ligatures" class="">"Call parameter type does not match function signature!"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">           CS.getArgument(i), FTy->getParamType(i), I);</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div><div>As you can see, it compares the type of the argument of the call to the type of the function declaration.</div><div>If you can print the IR before it fails, you can check how the function is declared.</div><div><br class=""></div><div>The quote you’re copy pasting is a bit strange, it is supposed to be over three lines like that:</div><div><br class=""></div><div><div><div class=""><div dir="ltr" class=""><div class=""><span id="gmail-docs-internal-guid-181a0bdb-15b4-34b1-66a4-ccfefd5e45b8" class=""><div class="" style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 13.3333px; font-family: 'source code pro'; color: rgb(255, 0, 0); vertical-align: baseline; white-space: pre-wrap;">Call parameter type does not match function signature</span><span class="" style="font-size: 13.3333px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap;">!</span></div><div class="" style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 13.3333px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap;">i8* getelementptr inbounds ([46 x i8], [46 x i8]* @instrname, i32 0, i32 0)</span></div><div class="" style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 13.3333px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap;">i8*  </span></div></span></div></div></div><div class=""><div dir="ltr" class=""><div class=""><span id="gmail-docs-internal-guid-181a0bdb-15b4-34b1-66a4-ccfefd5e45b8" class=""><div class="" style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 13.3333px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap;">%injectError = call i32 @myReferenceFunc(i32 %11, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @instrname, i32 0, i32 0), i32 -1)</span></div></span></div></div></div><div dir="ltr" class=""></div></div></div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><span id="gmail-docs-internal-guid-181a0bdb-15b4-34b1-66a4-ccfefd5e45b8" class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">The original function definition hasn't changed though.</span></div><br class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">We are using the current trunk of llvm.</span></div><br class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">Is there any related issue in the current trunk of llvm or if you could point us to something that has changed in llvm-39 that might be causing this difference ?</span></div><br class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">Note: For making our previous versions of passes compatible to llvm-39, we have replaced all the calls of </span><span style="font-size: 14.6667px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">getGlobalContext() </span><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">by </span><span style="font-size: 14.6667px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">*unwrap(LLVMGetGlobalContext()).</span></div><br class=""><div style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" class=""><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">We did try out a separate version modifying the llvm code to introduce the </span><span style="font-size: 14.6667px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">getGlobalContext()</span><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class=""> function as was available earlier to return the </span><span style="font-size: 14.6667px; font-family: 'source code pro'; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class="">*GlobalContext.</span><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class=""> Even with that we are seeing the same log.</span><span style="font-size: 14.6667px; font-family: arial; vertical-align: baseline; white-space: pre-wrap; background-color: transparent;" class=""><br class=""></span></div></span></div></div></div></blockquote><div><br class=""></div></div><br class=""><div class="">Since types are stored per context, it is very possible that it could be the source of the issue. However the change you are describing seems “OK” (the global context is not a great feature) providing it was working on 3.8 (and you’re initializing LLVM yourself, creating the module yourself in the global context, etc.). You can’t use you pass with opt with such a trick.</div><div class=""><br class=""></div><div class="">What you can do to verify if it is the source of the issue is to patch the code in the verifier from </div><div class=""><br class=""></div><div class="">  // Verify that all arguments to the call match the function type.<br class="">  for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)<br class="">    Assert(CS.getArgument(i)->getType() == FTy->getParamType(i),<br class="">           "Call parameter type does not match function signature!",<br class="">           CS.getArgument(i), FTy->getParamType(i), I);<br class=""><br class=""></div><div class="">To </div><div class=""><br class=""></div><div class="">  // Verify that all arguments to the call match the function type.<br class="">  for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++I) {<br class=""><div class="">    Assert(&CS.getArgument(i)->getType()->getContext() == &FTy->getParamType(i)->getContext(),<br class="">           “Context mismatch, internal error!",<br class="">           CS.getArgument(i), FTy->getParamType(i), I);</div>    Assert(CS.getArgument(i)->getType() == FTy->getParamType(i),<br class="">           "Call parameter type does not match function signature!",<br class="">           CS.getArgument(i), FTy->getParamType(i), I);</div><div class="">}<br class=""><br class=""></div><div class="">If the first assertion mismatch, you have some context issue.</div><div class=""><div><br class=""></div><div>— </div><div>Mehdi</div></div><div class=""><br class=""></div></body></html>