mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-13 14:47:00 +00:00
[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
This commit is contained in:
parent
bfb1922670
commit
1405564987
@ -1161,7 +1161,7 @@ class Record {
|
|||||||
// Tracks Record instances. Not owned by Record.
|
// Tracks Record instances. Not owned by Record.
|
||||||
RecordKeeper &TrackedRecords;
|
RecordKeeper &TrackedRecords;
|
||||||
|
|
||||||
DefInit *TheInit;
|
std::unique_ptr<DefInit> TheInit;
|
||||||
bool IsAnonymous;
|
bool IsAnonymous;
|
||||||
|
|
||||||
// Class-instance values can be used by other defs. For example, Struct<i>
|
// 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,
|
explicit Record(Init *N, ArrayRef<SMLoc> locs, RecordKeeper &records,
|
||||||
bool Anonymous = false) :
|
bool Anonymous = false) :
|
||||||
ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
|
ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
|
||||||
TrackedRecords(records), TheInit(nullptr), IsAnonymous(Anonymous),
|
TrackedRecords(records), IsAnonymous(Anonymous), ResolveFirst(false) {
|
||||||
ResolveFirst(false) {
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
explicit Record(const std::string &N, ArrayRef<SMLoc> locs,
|
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
|
// 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) :
|
Record(const Record &O) :
|
||||||
ID(LastID++), Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
|
ID(LastID++), Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
|
||||||
Values(O.Values), SuperClasses(O.SuperClasses),
|
Values(O.Values), SuperClasses(O.SuperClasses),
|
||||||
SuperClassRanges(O.SuperClassRanges), TrackedRecords(O.TrackedRecords),
|
SuperClassRanges(O.SuperClassRanges), TrackedRecords(O.TrackedRecords),
|
||||||
TheInit(O.TheInit), IsAnonymous(O.IsAnonymous),
|
IsAnonymous(O.IsAnonymous),
|
||||||
ResolveFirst(O.ResolveFirst) { }
|
ResolveFirst(O.ResolveFirst) { }
|
||||||
|
|
||||||
static unsigned getNewUID() { return LastID++; }
|
static unsigned getNewUID() { return LastID++; }
|
||||||
|
@ -1574,13 +1574,9 @@ void Record::checkName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefInit *Record::getDefInit() {
|
DefInit *Record::getDefInit() {
|
||||||
static DenseMap<Record *, std::unique_ptr<DefInit>> ThePool;
|
if (!TheInit)
|
||||||
if (TheInit)
|
TheInit.reset(new DefInit(this, new RecordRecTy(this)));
|
||||||
return TheInit;
|
return TheInit.get();
|
||||||
|
|
||||||
std::unique_ptr<DefInit> &I = ThePool[this];
|
|
||||||
if (!I) I.reset(new DefInit(this, new RecordRecTy(this)));
|
|
||||||
return I.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &Record::getName() const {
|
const std::string &Record::getName() const {
|
||||||
|
Loading…
Reference in New Issue
Block a user