extract_reduce: Fix segfault on "undriven" inputs
authorRobert Ou <rqou@robertou.com>
Tue, 12 Sep 2017 21:21:04 +0000 (14:21 -0700)
committerAndrew Zonenberg <azonenberg@drawersteak.com>
Thu, 14 Sep 2017 19:54:44 +0000 (12:54 -0700)
This is easily triggered when un-techmapping if the technology-specific
cell library isn't loaded. Outputs of technology-specific cells will be
seen as inputs, and nets using those outputs will be seen as undriven.
Just ignore these cells because they can't be part of a reduce chain
anyways.

passes/techmap/extract_reduce.cc

index 114015c233923ce3c5359683623013155ccd2000..54e45f83615c2dc59976863144f57b70db33f8ff 100644 (file)
@@ -160,7 +160,7 @@ struct ExtractReducePass : public Pass
                                        if (sig_to_sink[a[0]].size() + port_sigs.count(a[0]) == 1)
                                        {
                                                Cell* cell_a = sig_to_driver[a[0]];
-                                               if (((cell_a->type == "$_AND_" && gt == GateType::And) ||
+                                               if (cell_a && ((cell_a->type == "$_AND_" && gt == GateType::And) ||
                                                        (cell_a->type == "$_OR_" && gt == GateType::Or) ||
                                                        (cell_a->type == "$_XOR_" && gt == GateType::Xor)))
                                                {
@@ -177,7 +177,7 @@ struct ExtractReducePass : public Pass
                                        if (sig_to_sink[b[0]].size() + port_sigs.count(b[0]) == 1)
                                        {
                                                Cell* cell_b = sig_to_driver[b[0]];
-                                               if (((cell_b->type == "$_AND_" && gt == GateType::And) ||
+                                               if (cell_b && ((cell_b->type == "$_AND_" && gt == GateType::And) ||
                                                        (cell_b->type == "$_OR_" && gt == GateType::Or) ||
                                                        (cell_b->type == "$_XOR_" && gt == GateType::Xor)))
                                                {