Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Replace llvm::iplist<Instruction> with TaggedList<Instruction> in IRFunction #1766

Description

@stoklund

I want to introduce a new linked list data structure, TaggedList. This is an intrusive doubly linked list like llvm::iplist with the following differences:

  • Each node has a uint32_t tag member. These tags are maintained online in a strictly increasing order. This means that the relative position of elements in the list can be determined in (fast) constant time, even while inserting and removing elements from the list.
  • The list has a constant time size() operation, maintained as a member in the TaggedList class. This is needed for the online tag maintenance algorithm.
  • Splicing is a linear time operation because the new elements need to be tagged correctly. This is already the case for our specialization of transferNodesFromList().
  • The tag also makes it possible to detect when an end() iterator is dereferenced or incremented.

I have implemented a prototype of TaggedList based on the Two simplified algorithms for maintaining order in a list paper in order to run benchmarks. List insertions are O(log N) with excellent constant factors.

We already have class LiveIntervalsInstructionNumbering in IROptimizer.cpp. This change makes that class redundant by providing the same functionality while also allowing online instruction insertions.

The online instruction ordering is needed to implement advanced memory allocation and scheduling in backends.

Preemptively Answered Questions:

  • No, we can't extend llvm::iplist with this functionality because a) iplist::size() is linear time, and b) despite using 27 template classes for configuration and specialization, iplist doesn't offer the hooks needed.
  • No, we can't implement this as a hack in IRFunction because a) we need the constant time size() operator, and b) IRFunction::getInstrs() exposes the list implementation, and we can't prevent users from modifying the list and invalidating our side tables.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions