]> granicus.if.org Git - llvm/commitdiff
[gicombiner] Fix a nullptr dereference when -combiners is given a name that isn't...
authorDaniel Sanders <daniel_l_sanders@apple.com>
Wed, 2 Oct 2019 23:03:21 +0000 (23:03 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Wed, 2 Oct 2019 23:03:21 +0000 (23:03 +0000)
This is unlikely to be the root cause for the windows bot failures but
it would explain the stack trace seen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373543 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/GICombinerEmitter.cpp

index 7a9c87b6b936fa4eaa54bd24a57bd5a33c78ffe4..a85462b5aa89dfa9b6f71f05a6e5d4e69541d293 100644 (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