-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
irutil: add instruction and terminator operand use-tracking and value update API #1
base: master
Are you sure you want to change the base?
Conversation
… update API Rather than adding the use-tracking to llir/llvm/ir, we currently add this to irutil so we may get more experience with the API and see if its the right fit for instruction and terminator operand use-tracking and value update. Note: this is the stronger version of the API, as outlined by @pwaller in llir/llvm#42 (comment) Notably, operands are tracked by pointer (*value.Value) which also enables updating values using the same API. Fixes llir/llvm#42.
…tUses Note: we should try to arrive at a more general way of handling custom user-defined instructions.
…ue operands Without this change, repeated invokations of InstUses (as used in FuncUses) would result in incorrect results. for _, inst := range block.Insts { backing = InstUses(backing, inst) }
Since we already track a pointer to the used value in the Use structure, we can pass Use by value. This should help reduce memory allocations.
Further thoughts. I think that
I realise this means that I envisage a A note on naming: func foo(in []bar) (out []bar) {
out = in
...
out = append(out, extra...)
} ... but please adjust to your (good) taste! :) The other thing in the back of my mind is - how are we going to maintain the sets of |
Note: this implementation of dce is a toy example. It does not take deep value uses into account, and as such, cannot handle use tracking when local variables are used within constant expressions. This issue would be resolved when irutil.FuncUses is extended to handle deep value use tracking.
I've added an example use case of the API to get a better feel for the use-tracking API. For use-tracking, see the dead code elimination example at: https://github.com/llir/irutil/blob/503ea997aa34863b1a261bd5c0a93a46245cb371/example_test.go And for used value modification, see the NOP |
Indeed,
Yeah, using
Agreed. Using methods for
Yeah, methods is most likely the way to go, for v0.4 that is :)
Thanks for sharing your thoughts on this Peter! I think it definitely helped us move closer to a good use-tracking API, and solves the already identified issue of "custom" instructions ("custom" anything use-tracking related really, e.g. perhaps a "custom" constant expression).
Agreed.
I have no idea yet :) That's essentially the main reason I want to keep the use-tracking API in |
Note, the v0.3.0 release had a few changes to the API. The most intrusive one may be to use value.Value in all places where operands of instructions are used. This has both pros and cons, where the cons include less exact types used for instruction and terminator operands. The benefit is that this change enable a unified and quite powerful use-tracking API, as further outlined in llir/llvm#50, llir/llvm#122 and llir/irutil#1.
Rather than adding the use-tracking to llir/llvm/ir, we currently add
this to irutil so we may get more experience with the API and see if its
the right fit for instruction and terminator operand use-tracking and
value update.
Note: this is the stronger version of the API, as outlined by @pwaller
in llir/llvm#42 (comment)
Notably, operands are tracked by pointer (*value.Value) which also enables
updating values using the same API.
Fixes llir/llvm#42.
Updates llir/llvm#19 (note, we don't do deep use tracking in this PR, so llir/llvm#19 is only partially fixed).
cc: @pwaller and @dannypsnl