[llvm] r258297 - [Verifier] Fix performance regression for LTO builds
Ivan Krasin via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 20 00:41:24 PST 2016
Author: krasin
Date: Wed Jan 20 02:41:22 2016
New Revision: 258297
URL: http://llvm.org/viewvc/llvm-project?rev=258297&view=rev
Log:
[Verifier] Fix performance regression for LTO builds
Summary:
Fix a significant performance regression by introducing GlobalValueVisited field and reusing the map.
This is a follow up to r257823 that slowed down linking Chrome with LTO by 2.5x.
If you revert this commit, please, also revert r257823.
BUG=https://llvm.org/bugs/show_bug.cgi?id=26214
Reviewers: pcc, loladiro, joker.eph
Subscribers: krasin1, joker.eph, loladiro, pcc
Differential Revision: http://reviews.llvm.org/D16338
Modified:
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=258297&r1=258296&r2=258297&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Wed Jan 20 02:41:22 2016
@@ -217,6 +217,12 @@ class Verifier : public InstVisitor<Veri
/// Cache of constants visited in search of ConstantExprs.
SmallPtrSet<const Constant *, 32> ConstantExprVisited;
+ // Verify that this GlobalValue is only used in this module.
+ // This map is used to avoid visiting uses twice. We can arrive at a user
+ // twice, if they have multiple operands. In particular for very large
+ // constant expressions, we can arrive at a particular user many times.
+ SmallPtrSet<const Value *, 32> GlobalValueVisited;
+
void checkAtomicMemAccessSize(const Module *M, Type *Ty,
const Instruction *I);
public:
@@ -494,12 +500,7 @@ void Verifier::visitGlobalValue(const Gl
if (GV.isDeclarationForLinker())
Assert(!GV.hasComdat(), "Declaration may not be in a Comdat!", &GV);
- // Verify that this GlobalValue is only used in this module.
- // This map is used to avoid visiting uses twice. We can arrive at a user
- // twice, if they have multiple operands. In particular for very large
- // constant expressions, we can arrive at a particular user many times.
- SmallPtrSet<const Value *, 32> Visited;
- forEachUser(&GV, Visited, [&](const Value *V) -> bool {
+ forEachUser(&GV, GlobalValueVisited, [&](const Value *V) -> bool {
if (const Instruction *I = dyn_cast<Instruction>(V)) {
if (!I->getParent() || !I->getParent()->getParent())
CheckFailed("Global is referenced by parentless instruction!", &GV,
More information about the llvm-commits
mailing list