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
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.This becomes inefficient for large programs.
Current Behavior
Expected Behavior
Suggested Direction