diff options
author | Matthias Braun <matze@braunis.de> | 2016-12-05 06:41:47 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2016-12-05 06:41:47 +0000 |
commit | 2ba1a51cf5676488e885d7097fd07875fae44da3 (patch) | |
tree | 77b2dc5f63b4adfde35f6b1b4c6f6bf348b15212 /lib/TableGen | |
parent | 1fcb0c52749b6517c5ab0ecd9b66d57576bf8200 (diff) |
ListInit::convertInitializerTo: avoid foldingset lookup if nothing changed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288647 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen')
-rw-r--r-- | lib/TableGen/Record.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 2875375f4cd..de13cd2246a 100644 --- a/lib/TableGen/Record.cpp +++ b/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; |