Skip to content

Inefficient IR List Construction (O(n²)) #14

@SAMBA8695

Description

@SAMBA8695

Description

IR instructions are stored in a singly linked list. Each call to append_ir() traverses the entire list to find the end, resulting in quadratic time complexity during IR generation.

while (temp->next != NULL) {
    temp = temp->next;
}

This becomes inefficient for large programs.

Current Behavior

  • Appending IR instructions is O(n)
  • Generating n instructions results in O(n²) time complexity
  • Performance degrades rapidly as program size grows

Expected Behavior

  • IR construction should be linear time
  • Appending instructions should be O(1)

Suggested Direction

  • Maintain a tail pointer for the IR list
  • Or use a dynamic array/vector structure
  • Optionally refactor IR into basic blocks

Metadata

Metadata

Assignees

No one assigned

    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