Skip to content

Commit

Permalink
[gicombiner] Fix a nullptr dereference when -combiners is given a nam…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
dsandersllvm committed Oct 2, 2019
1 parent ae3315a commit 2a964ea
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions llvm/utils/TableGen/GICombinerEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -41,8 +42,9 @@ class GICombinerEmitter {

};

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",
Expand Down Expand Up @@ -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

0 comments on commit 2a964ea

Please sign in to comment.