1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[gicombiner] Fix a nullptr dereference when -combiners is given a name that isn't defined

This is unlikely to be the root cause for the windows bot failures but
it would explain the stack trace seen.

llvm-svn: 373543
This commit is contained in:
Daniel Sanders 2019-10-02 23:03:21 +00:00
parent 969fdec45b
commit fb64fe5ff8

View File

@ -31,7 +31,8 @@ class GICombinerEmitter {
StringRef Name;
Record *Combiner;
public:
explicit GICombinerEmitter(RecordKeeper &RK, StringRef Name);
explicit GICombinerEmitter(RecordKeeper &RK, StringRef Name,
Record *Combiner);
~GICombinerEmitter() {}
StringRef getClassName() const {
@ -41,8 +42,9 @@ public:
};
GICombinerEmitter::GICombinerEmitter(RecordKeeper &RK, StringRef Name)
: Name(Name), Combiner(RK.getDef(Name)) {}
GICombinerEmitter::GICombinerEmitter(RecordKeeper &RK, StringRef Name,
Record *Combiner)
: Name(Name), Combiner(Combiner) {}
void GICombinerEmitter::run(raw_ostream &OS) {
NamedRegionTimer T("Emit", "Time spent emitting the combiner",
@ -87,8 +89,12 @@ void EmitGICombiner(RecordKeeper &RK, raw_ostream &OS) {
if (SelectedCombiners.empty())
PrintFatalError("No combiners selected with -combiners");
for (const auto &Combiner : SelectedCombiners)
GICombinerEmitter(RK, Combiner).run(OS);
for (const auto &Combiner : SelectedCombiners) {
Record *CombinerDef = RK.getDef(Combiner);
if (!CombinerDef)
PrintFatalError("Could not find " + Combiner);
GICombinerEmitter(RK, Combiner, CombinerDef).run(OS);
}
}
} // namespace llvm