do not use new_Bad(), as this depends on current_ir_graph, cast
[libfirm] / ir / ir / irnode.c
index 708ac70..997318e 100644 (file)
@@ -41,6 +41,7 @@
 #include "irprog_t.h"
 #include "iredgekinds.h"
 #include "iredges_t.h"
+#include "ircons.h"
 
 #include "irhooks.h"
 #include "irtools.h"
@@ -879,8 +880,12 @@ ir_node *get_Block_MacroBlock(const ir_node *block) {
 
 /* returns the macro block header of a node. */
 ir_node *get_irn_MacroBlock(const ir_node *n) {
-       if (! is_Block(n))
+       if (! is_Block(n)) {
                n = get_nodes_block(n);
+               /* if the Block is Bad, do NOT try to get it's MB, it will fail. */
+               if (is_Bad(n))
+                       return (ir_node *)n;
+       }
        return get_Block_MacroBlock(n);
 }