-
Notifications
You must be signed in to change notification settings - Fork 78
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
Use tracking #19
Comments
The simplest thing that could possibly work would be to make Instructions and Terminators fulfill this interface: interface ValueUser {
ValuesUsed() []Value
} Then users of the package could implement their own use tracking without needing a giant type switch; they could treat all ValueUsers alike. But once you've done that, building a map from Values to ValueUsers would be simple enough that you might as well do it too: func FindUsers(f *ir.Func) map[Value][]ValueUser |
Looks great. The From #191 (comment): Suggested re-definition of package ir
// Instruction is an LLVM IR instruction. All instructions (except store and
// fence) implement the value.Named interface and may thus be used directly as
// values.
//
// An Instruction has one of the following underlying types.
//
// ...
type Instruction interface {
LLStringer
// isInstruction ensures that only instructions can be assigned to the
// instruction.Instruction interface.
isInstruction()
// Operands returns a mutable list of operands of the instruction.
Operands() []*value.Value
} And correspondingly for package ir
// Terminator is an LLVM IR terminator instruction (a control flow instruction).
//
// A Terminator has one of the following underlying types.
//
// ...
type Terminator interface {
LLStringer
// Succs returns the successor basic blocks of the terminator.
Succs() []*Block
// Operands returns a mutable list of operands of the terminator.
Operands() []*value.Value
} Essentially, the only difference between the I propose we go ahead with implementing the The package value
// ValueUser is an instruction or terminator which uses values as operands.
type ValueUser interface {
// Operands returns a mutable list of operands of the value user (instruction or terminator).
Operands() []*Value
} @andybalholm and @dannypsnl, what are your thoughts on this API? Cheers, |
Sounds good to me. I'm not sure if ValueUser is the best name for the interface if the method is named Operands, but I don't know what name to suggest. |
I think it's fine. If we figure out a better one while implementing the feature, we can change it. How about |
So we only need to merge operands branch? |
Yes, I think |
Almost. The operands branch still used non-mutable lists for operands. I made a new PR (#214) returning a mutable list from the Cheers, |
The issue is intended to track discussions and experimental implementation related to use tracking.
The C++ API of LLVM defines the concepts of a
Use
and aUser
. AUse
is an edge between a used value and its user. EachUser
has a number of operands which specify theUse
d values. Pseudo code follows:Anyone is invited to join the discussion. How would users of the API which to use it? May it be implemented by a dedicated package separate from the
ir
package? How would the interaction work? May there co-exist several implementations of use-tracking, and is this ever useful?The text was updated successfully, but these errors were encountered: