AsmWriter: Avoid O(N^2) processing of metadata
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 11 Sep 2015 01:34:59 +0000 (01:34 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 11 Sep 2015 01:34:59 +0000 (01:34 +0000)
commit812e1e45de5aac14029573e9fb81885922a2120b
tree55e7c7aac873b3afb21c4163bc740f4a5b6f4738
parent5db31461109dbf8e9a12a78e3128849461d1a2e2
AsmWriter: Avoid O(N^2) processing of metadata

Fix embarrassing bugs I introduced to the `SlotTracker` in or around
r235785.  I had us iterating through every instruction in a function
(and hitting a map in the LLVMContext) for every basic block in the
function.

While there, completely avoid the call to
`SlotTracker::processFunctionMetadata()` from
`SlotTracker::processFunction()` if we've speculatively done this
already in `SlotTracker::processModule()` by checking
`ShouldInitializeAllMetadata` (this wasn't an algorithmic problem, but
it's touching the same line of code).

Fixes PR24699.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247372 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/AsmWriter.cpp