# IRTools need help: purge unused arguments from argument list of a function

**URL:** <https://discourse.julialang.org/t/irtools-need-help-purge-unused-arguments-from-argument-list-of-a-function/86431>\
**Category:** General Usage\
**Tags:** question, package, ir\
**Created:** [August 27, 2022, 1:53pm UTC](https://discourse.julialang.org/t/irtools-need-help-purge-unused-arguments-from-argument-list-of-a-function/86431 "2022-08-27T13:53:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Lian\_Yunlong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lian_yunlong/32/14437_2.png) [@Lian\_Yunlong](https://discourse.julialang.org/u/Lian_Yunlong)\
**Post date:** [August 27, 2022, 2:02pm UTC](https://discourse.julialang.org/t/irtools-need-help-purge-unused-arguments-from-argument-list-of-a-function/86431/2 "2022-08-27T14:02:20Z")

</div>

> [@Transform CodeInfo of a function to get a new function by purging unused args from its arg list](https://discourse.julialang.org/t/transform-codeinfo-of-a-function-to-get-a-new-function-by-purging-unused-args-from-its-arg-list/87459/2):
>
> This code should work. function assign\_purge\_argument!(@nospecialize(p::Pair{\<:Function,\<:Function}), rule::Pair{Int,\<:Any}) (src, dst) = p (nth, value) = rule @assert length(methods(src)) == 1 "assign\_purge\_argument!(src=\>dst, n=\>val) requires src to have only one method." mod = getmodule(dst) function change\_slotnumber\_after\_nth(s) if s isa Core.SlotNumber return (s.id==nth+1) ? value : (s.id\>nth+1 ? Core.SlotNumber(s.id-1) : s) else …

Achieved the goal without using `IRTools.jl` but I am still hoping to use it correctly…

---

_[View the full topic](https://discourse.julialang.org/t/irtools-need-help-purge-unused-arguments-from-argument-list-of-a-function/86431)._
