Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function should store Arguments contiguously not in an iplist #16910

Closed
llvmbot opened this issue Jul 4, 2013 · 0 comments
Closed

Function should store Arguments contiguously not in an iplist #16910

llvmbot opened this issue Jul 4, 2013 · 0 comments
Labels
bugzilla Issues migrated from bugzilla llvm:core

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 4, 2013

Bugzilla Link 16536
Resolution FIXED
Resolved on Apr 30, 2020 13:05
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @ekatz
Fixed by commit(s) rL298105

Extended Description

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.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:core
Projects
None yet
Development

No branches or pull requests

1 participant