llvm.org GIT mirror llvm / 1405564
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240524 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 5 years ago
2 changed file(s) with 8 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
11601160 // Tracks Record instances. Not owned by Record.
11611161 RecordKeeper &TrackedRecords;
11621162
1163 DefInit *TheInit;
1163 std::unique_ptr TheInit;
11641164 bool IsAnonymous;
11651165
11661166 // Class-instance values can be used by other defs. For example, Struct
11831183 explicit Record(Init *N, ArrayRef locs, RecordKeeper &records,
11841184 bool Anonymous = false) :
11851185 ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
1186 TrackedRecords(records), TheInit(nullptr), IsAnonymous(Anonymous),
1187 ResolveFirst(false) {
1186 TrackedRecords(records), IsAnonymous(Anonymous), ResolveFirst(false) {
11881187 init();
11891188 }
11901189 explicit Record(const std::string &N, ArrayRef locs,
11931192
11941193
11951194 // When copy-constructing a Record, we must still guarantee a globally unique
1196 // ID number. All other fields can be copied normally.
1195 // ID number. Don't copy TheInit either since it's owned by the original
1196 // record. All other fields can be copied normally.
11971197 Record(const Record &O) :
11981198 ID(LastID++), Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
11991199 Values(O.Values), SuperClasses(O.SuperClasses),
12001200 SuperClassRanges(O.SuperClassRanges), TrackedRecords(O.TrackedRecords),
1201 TheInit(O.TheInit), IsAnonymous(O.IsAnonymous),
1201 IsAnonymous(O.IsAnonymous),
12021202 ResolveFirst(O.ResolveFirst) { }
12031203
12041204 static unsigned getNewUID() { return LastID++; }
15731573 }
15741574
15751575 DefInit *Record::getDefInit() {
1576 static DenseMap> ThePool;
1577 if (TheInit)
1578 return TheInit;
1579
1580 std::unique_ptr &I = ThePool[this];
1581 if (!I) I.reset(new DefInit(this, new RecordRecTy(this)));
1582 return I.get();
1576 if (!TheInit)
1577 TheInit.reset(new DefInit(this, new RecordRecTy(this)));
1578 return TheInit.get();
15831579 }
15841580
15851581 const std::string &Record::getName() const {