[NFC] ConstantMerge: don't insert when find should be used
authorJF Bastien <jfbastien@apple.com>
Thu, 9 Aug 2018 04:17:48 +0000 (04:17 +0000)
committerJF Bastien <jfbastien@apple.com>
Thu, 9 Aug 2018 04:17:48 +0000 (04:17 +0000)
commit3f270336e1c4e69ead7d7f78e3d2f9c1d859f40d
tree99e32444a672652e19c1578fec676d62f4b651cd
parent22b20a09a08baba62f69f19e65c79b59f15cb0e0
[NFC] ConstantMerge: don't insert when find should be used

Summary: DenseMap's operator[] performs an insertion if the entry isn't found. The second phase of ConstantMerge isn't trying to insert anything: it's just looking to see if the first phased performed an insertion. Use find instead, avoiding insertion of every single global initializer in the map of constants. This has the side-effect of making all entries in CMap non-null (because only global declarations would have null initializers, and that would be a bug).

Subscribers: dexonsmith, llvm-commits

Differential Revision: https://reviews.llvm.org/D50476

llvm-svn: 339309
llvm/lib/Transforms/IPO/ConstantMerge.cpp