LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 16536 - Function should store Arguments contiguously not in an iplist
Summary: Function should store Arguments contiguously not in an iplist
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Core LLVM classes (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-03 20:07 PDT by Nick Lewycky
Modified: 2020-04-30 13:05 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s): rL298105


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Lewycky 2013-07-03 20:07:51 PDT
Functions are created separately from their Argument list, which is stored as a linked list. The Argument list is inseparably tied to the type of the function, which is an immutable property of the function when created. We aren't benefiting from giving Argument lists efficient insertion you need to destroy and recreate the whole Function regardless.

Instead, we should contiguously allocate the space for the arguments and construct them when the function is created, and destroy them when the function is destroyed.

Pros:
 - Efficient random access to the n-th Argument*.
 - One fewer allocation for the function and arguments.
 - Saves two pointers per Argument, since there's no more ilist_node<> for each one.
 - Argument::getArgNo() could be reimplemented as O(1) using pointer subtraction instead of the present O(n) list walk.

Cons:
 - No longer be efficient to swap two same-typed arguments.
 - No longer lazily create the argument list.
 - No longer support polymorphic Arguments (in case we do already).

This gives us the nice property that we could walk from a callsite parameter operand number to a function's n-th argument in constant time.