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

李阳 via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 23 22:24:01 PDT 2017


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        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170324/6648b45b/attachment.html>


More information about the llvm-dev mailing list