<div dir="ltr">Sounds like you're getting hit by the typeless pointer work I  started a few years ago (not quite finished, unfortunately)<br><br>Specifically, I think the type of a Function should be the Function type, not the PointerType - but I don't recall precisely.<br><br>Also I think mutateType is a pretty specialized API mostly/only used for IR linking... not sure it's what you want to be using more broadly. Probably creating a new Function and RAUW'ing it? Not sure.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Mar 23, 2017 at 10:24 PM 李阳 via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Hi all,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Recently I have implemented a transformation pass based on LLVM3.5 and its function is to duplicate the function's argument list in a bytecode file and replace all use of original function with modified function. In LLVM3.5, the pass can work properly. However, when I tried to transplant the pass to LLVM3.9, the error "Argument value does not match function argument type!" occured.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The core snippet of my pass is as follows: 'func' denotes original function in a Module; 'new_return_type' denotes the duplicate of original function's return type; 'arg_types' denotes the duplicated argument type.</div><div class="gmail_msg">And I have analysed the cause of error "Argument value does not match function argument type!" and I can determine that the error APIs are mutateType()(3rd line)or getArgumentList().insertAfter()(10th line) between LLVM3.5 and LLVM3.9.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Anyone came across the same problem or knew the error API above? Thanks a lot!</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg">1         unsigned address_space  = func->getType()->getAddressSpace();</div><div class="gmail_msg">2        FunctionType *new_type = FunctionType::get(new_return_type, arg_types, type->isVarArg(    ));</div><div class="gmail_msg">3         func->mutateType(PointerType::get(new_type, address_space));</div><div class="gmail_msg">4         //Duplicate arguments</div><div class="gmail_msg">5         std::vector<Argument *> arg_list;</div><div class="gmail_msg">6         for each_custom(arg, *func, arg_begin, arg_end)</div><div class="gmail_msg">7           arg_list.push_back(&*arg);</div><div class="gmail_msg">8         for each(arg, arg_list){</div><div class="gmail_msg">9           Argument *arg_dup = new Argument((*arg)->getType(), makeName(*arg, "_dup"));</div><div class="gmail_msg">10           func->getArgumentList().insertAfter((*arg)->getIterator(), arg_dup);</div><div class="gmail_msg">11        }</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div></div>
_______________________________________________<br class="gmail_msg">
LLVM Developers mailing list<br class="gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="gmail_msg">
</blockquote></div>