<div class="gmail_quote">Hi Anton<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><br>
> The interesting for me part of the CallInst is printf(i8* noalias %0, i32<br>
> 123).<br>
> I was diging in doxygen documentation but I really can't see the easy way to<br>
> compare those instructions and again finish with reinvented (but working)<br>
> wheel ;).<br>
</div>Ah, sorry. I missed that you're doing variadic calls, not casting<br>
variadic function to definite ones. I think you can construct CallSite<br>
and then iterate over the arguments grabbing their types and construct<br>
function type after that.<br>
</blockquote></div><br>So what do you think about that:<br><br>// CallSites have equal signatures<br>bool MSILWriter::cmpCallSite(CallSite A, CallSite B) {<br>  return (getCallSiteFType(A)==getCallSiteFType(B) && <br>
    A.getAttributes()==B.getAttributes());  <br>}<br><br>// Comparision for std::lower_bound used in MSILWriter::printExternals()<br>bool MSILWriter::compareCallSite(CallSite A, CallSite B) { <br>  return getCallSiteFType(A)<getCallSiteFType(B);<br>
}<br><br>// Constructs function type from given CallSite<br>FunctionType* MSILWriter::getCallSiteFType(CallSite CS) {<br>  std::vector<const Type *> params;<br>  CallSite::arg_iterator AI=CS.arg_begin(), AE = CS.arg_end();<br>
  for ( ; AI!=AE; ++AI )<br>    params.push_back((*AI)->getType());<br>  return FunctionType::get(CS.getCalledFunction()->getReturnType(),<br>    params,CS.getCalledFunction()->isVarArg());<br>}<br><br>Thanks!<br>
Regards,<br>Artur<br><br>