summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2016-12-05 06:41:47 +0000
committerMatthias Braun <matze@braunis.de>2016-12-05 06:41:47 +0000
commitdbe6e7de9e8893c36c3306680e62d027e122cd95 (patch)
tree9c2dd0c0b351f4eb079aa26cd8b46f233a1fa974 /llvm/lib
parent088ba17f885964c526182acda9b670489b53ddba (diff)
downloadbcm5719-llvm-dbe6e7de9e8893c36c3306680e62d027e122cd95.tar.gz
bcm5719-llvm-dbe6e7de9e8893c36c3306680e62d027e122cd95.zip
ListInit::convertInitializerTo: avoid foldingset lookup if nothing changed
llvm-svn: 288647
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/TableGen/Record.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 2875375f4cd..de13cd2246a 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -533,19 +533,28 @@ void ListInit::Profile(FoldingSetNodeID &ID) const {
}
Init *ListInit::convertInitializerTo(RecTy *Ty) const {
+ if (getType() == Ty)
+ return const_cast<ListInit*>(this);
+
if (auto *LRT = dyn_cast<ListRecTy>(Ty)) {
std::vector<Init*> Elements;
+ Elements.reserve(getValues().size());
// Verify that all of the elements of the list are subclasses of the
// appropriate class!
+ bool Changed = false;
+ RecTy *ElementType = LRT->getElementType();
for (Init *I : getValues())
- if (Init *CI = I->convertInitializerTo(LRT->getElementType()))
+ if (Init *CI = I->convertInitializerTo(ElementType)) {
Elements.push_back(CI);
- else
+ if (CI != I)
+ Changed = true;
+ } else
return nullptr;
- if (isa<ListRecTy>(getType()))
- return ListInit::get(Elements, Ty);
+ if (!Changed)
+ return const_cast<ListInit*>(this);
+ return ListInit::get(Elements, Ty);
}
return nullptr;
OpenPOWER on IntegriCloud