[PATCH] D31261: [IR] De-virtualize ~Value to save a vptr
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 22 14:32:16 PDT 2017
rnk created this revision.
Herald added subscribers: Prazek, mzolotukhin.
This patch is intended as an overview of all the changes required to
devirtualize Value. This patch needs to be split up and parts of it
aren't acceptable at all, but I'm posting this to get some discussion
Removing the virtual table pointer from Value saves 1% of RSS when doing
LTO of llc on Linux. The impact on time was positive, but too noisy to
conclusively say that performance improved. Here is a link to the
spreadsheet with the original data:
This change makes it invalid to directly delete a Value, User, or
Instruction pointer. Instead, such code can be rewritten to a null check
and a call Value::deleteValue(). Value objects tend to have their
lifetimes managed through iplist, so for the most part, this is an
internal implementation detail. However, there are some places where
LLVM deletes values, and those places had to be migrated to deleteValue.
I have also created llvm::unique_value, which has a custom deleter, so
it can be used in place of std::unique_ptr<Value>.
I had to add the "ValueCallbacks" escape hatch for MemorySSA, which
derives from User outside of lib/IR. Code in IR cannot include MemorySSA
headers or call the MemoryAccess object destructors without introducing
a circular dependency, so we need some level of indirection.
Unfortunately, no class derived from User may have any virtual methods,
because adding a virtual method would break User::getHungOffOperands(),
which assumes that it can find the use list immediately prior to the
User object. Adding virtual methods anywhere in the hierarchy will
compile, but any attempt to use the use list will crash with confusing
assertions. I think we need some way of checking this at compile time,
because developers are going to trip over this.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 68223 bytes
Desc: not available
More information about the llvm-commits