[llvm-dev] Problem about API difference between LLVM3.5 and LLVM3.9

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 24 11:47:33 PDT 2017


Sounds like you're getting hit by the typeless pointer work I  started a
few years ago (not quite finished, unfortunately)

Specifically, I think the type of a Function should be the Function type,
not the PointerType - but I don't recall precisely.

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.

On Thu, Mar 23, 2017 at 10:24 PM 李阳 via llvm-dev <llvm-dev at lists.llvm.org>
wrote:

> Hi all,
>
> 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.
>
> 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.
> 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.
>
> Anyone came across the same problem or knew the error API above? Thanks a
> lot!
>
> 1         unsigned address_space  = func->getType()->getAddressSpace();
> 2        FunctionType *new_type = FunctionType::get(new_return_type,
> arg_types, type->isVarArg(    ));
> 3         func->mutateType(PointerType::get(new_type, address_space));
> 4         //Duplicate arguments
> 5         std::vector<Argument *> arg_list;
> 6         for each_custom(arg, *func, arg_begin, arg_end)
> 7           arg_list.push_back(&*arg);
> 8         for each(arg, arg_list){
> 9           Argument *arg_dup = new Argument((*arg)->getType(),
> makeName(*arg, "_dup"));
> 10           func->getArgumentList().insertAfter((*arg)->getIterator(),
> arg_dup);
> 11        }
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170324/13351411/attachment.html>


More information about the llvm-dev mailing list