OSDN Git Service

SDAG: Avoid a large, usually empty SmallVector in a recursive function
authorJustin Bogner <mail@justinbogner.com>
Fri, 2 Dec 2016 00:11:01 +0000 (00:11 +0000)
committerJustin Bogner <mail@justinbogner.com>
Fri, 2 Dec 2016 00:11:01 +0000 (00:11 +0000)
commitd937b699b80714652f6401815c9835a1136a2319
tree5dc1c64e6d4c6422b392f2a2b7e1ba9fc35ba9f2
parentc7cf225724b845fa54304bd851145a5c758581d2
SDAG: Avoid a large, usually empty SmallVector in a recursive function

This SmallVector is using up 128 bytes on the stack every time despite
almost always being empty[1], and since this function can recurse quite
deeply that adds up to a lot of overhead. We've seen this run afoul of
ulimits in some cases with ASAN on.

Replacing the SmallVector with a std::vector trades an occasional heap
allocation for vastly less stack usage.

[1]: I gathered some stats on an internal test suite and the vector
was non-empty in only 45,000 of 10,000,000 calls to this function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288441 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/LegalizeTypes.cpp