[LLVMbugs] [Bug 21438] New: Separate User from the Value inheritance hierarchy

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Oct 31 17:55:35 PDT 2014


            Bug ID: 21438
           Summary: Separate User from the Value inheritance hierarchy
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Core LLVM classes
          Assignee: unassignedbugs at nondot.org
          Reporter: dexonsmith at apple.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Currently, `User` inherits from `Value`.  Most subclasses of `Value` -- even
those that don't have the concept of an operand -- inherit from `User`.

Instead, we should separate `User` from the `Value` inheritance hierarchy.

The current model is strange for operand-less `Instruction`s and `Constant`s. 
Moreover, it makes the inheritance structure of the new metadata types from bug
21432 especially awkward [1].

[1]: http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-October/078261.html
    See the comments about the relationships between MDNode/MDString/MDUser.

**Design needed.**  Nevertheless, here's the sketch of a straw man:

 1. `Value` has a bit indicating whether it's a `User` (perhaps borrowed from
`ValueName *Name`).

 2. `Use::getUser()` returns `Value` and asserts that the bit is set. 
Alternatively, it returns a wrapper around `Value *` called `UserRef` that has
operand-related API.

 3. Eventual subclasses of `Value` that have operands use multiple inheritance
to inherit from `User`.  Note that every child of `User` already needs to
specialize `User` with `OperandTraits`, so this doesn't add boilerplate -- in
fact, it should clean it up a bit.

 4. Change the `Use *OperandList` in `User` to be allocated in front of it
(like the operands in `FixedNumOperandTraits`).  This makes it accessible from
`Value` without knowing the common subclass between `Value` and `User`.

I won't have time in the short-term to design, qualify, and roll this out, but
I thought I'd get the idea down while the issues are paged in.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141101/a192a10d/attachment.html>

More information about the llvm-bugs mailing list