summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2015-06-24 06:19:19 +0000
committerCraig Topper <craig.topper@gmail.com>2015-06-24 06:19:19 +0000
commita60ee86f607c537d4f7e02948bce810d6f2b9b29 (patch)
treeeb3a7f18cb598896988ef27731935f88079e4d9b /llvm
parent8d6b6f239e65064cee7e5ca6e57bcee0c63cf445 (diff)
downloadbcm5719-llvm-a60ee86f607c537d4f7e02948bce810d6f2b9b29.tar.gz
bcm5719-llvm-a60ee86f607c537d4f7e02948bce810d6f2b9b29.zip
[TableGen] Restore the use of the TheInit field in Record to cache the Record's DefInit. I broke this when I fixed memory leaks recently. Remove the DenseMap that mapped Record's to DefInit.
llvm-svn: 240524
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/TableGen/Record.h10
-rw-r--r--llvm/lib/TableGen/Record.cpp10
2 files changed, 8 insertions, 12 deletions
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index 5760a1cf9a4..717a2a4ba62 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1161,7 +1161,7 @@ class Record {
// Tracks Record instances. Not owned by Record.
RecordKeeper &TrackedRecords;
- DefInit *TheInit;
+ std::unique_ptr<DefInit> TheInit;
bool IsAnonymous;
// Class-instance values can be used by other defs. For example, Struct<i>
@@ -1184,8 +1184,7 @@ public:
explicit Record(Init *N, ArrayRef<SMLoc> locs, RecordKeeper &records,
bool Anonymous = false) :
ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
- TrackedRecords(records), TheInit(nullptr), IsAnonymous(Anonymous),
- ResolveFirst(false) {
+ TrackedRecords(records), IsAnonymous(Anonymous), ResolveFirst(false) {
init();
}
explicit Record(const std::string &N, ArrayRef<SMLoc> locs,
@@ -1194,12 +1193,13 @@ public:
// When copy-constructing a Record, we must still guarantee a globally unique
- // ID number. All other fields can be copied normally.
+ // ID number. Don't copy TheInit either since it's owned by the original
+ // record. All other fields can be copied normally.
Record(const Record &O) :
ID(LastID++), Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
Values(O.Values), SuperClasses(O.SuperClasses),
SuperClassRanges(O.SuperClassRanges), TrackedRecords(O.TrackedRecords),
- TheInit(O.TheInit), IsAnonymous(O.IsAnonymous),
+ IsAnonymous(O.IsAnonymous),
ResolveFirst(O.ResolveFirst) { }
static unsigned getNewUID() { return LastID++; }
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 97e796c1349..6e982bf1da1 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -1574,13 +1574,9 @@ void Record::checkName() {
}
DefInit *Record::getDefInit() {
- static DenseMap<Record *, std::unique_ptr<DefInit>> ThePool;
- if (TheInit)
- return TheInit;
-
- std::unique_ptr<DefInit> &I = ThePool[this];
- if (!I) I.reset(new DefInit(this, new RecordRecTy(this)));
- return I.get();
+ if (!TheInit)
+ TheInit.reset(new DefInit(this, new RecordRecTy(this)));
+ return TheInit.get();
}
const std::string &Record::getName() const {
OpenPOWER on IntegriCloud