add a big diagnostic for failures in CmmCvt.toZgraph
authorNorman Ramsey <nr@eecs.harvard.edu>
Tue, 11 Sep 2007 14:23:38 +0000 (14:23 +0000)
committerNorman Ramsey <nr@eecs.harvard.edu>
Tue, 11 Sep 2007 14:23:38 +0000 (14:23 +0000)
compiler/cmm/CmmCvt.hs

index 35ebb4f..7b22958 100644 (file)
@@ -27,7 +27,7 @@ cmmOfZgraph = cmmMapGraph  ofZgraph
 
 toZgraph :: String -> ListGraph CmmStmt -> UniqSM CmmGraph
 toZgraph _ (ListGraph []) = lgraphOfAGraph emptyAGraph
 
 toZgraph :: String -> ListGraph CmmStmt -> UniqSM CmmGraph
 toZgraph _ (ListGraph []) = lgraphOfAGraph emptyAGraph
-toZgraph fun_name (ListGraph (BasicBlock id ss : other_blocks)) = 
+toZgraph fun_name g@(ListGraph (BasicBlock id ss : other_blocks)) = 
            labelAGraph id $ mkStmts ss <*> foldr addBlock emptyAGraph other_blocks
   where addBlock (BasicBlock id ss) g = mkLabel id   <*> mkStmts ss <*> g
         mkStmts (CmmNop        : ss)  = mkNop        <*> mkStmts ss 
            labelAGraph id $ mkStmts ss <*> foldr addBlock emptyAGraph other_blocks
   where addBlock (BasicBlock id ss) g = mkLabel id   <*> mkStmts ss <*> g
         mkStmts (CmmNop        : ss)  = mkNop        <*> mkStmts ss 
@@ -43,8 +43,7 @@ toZgraph fun_name (ListGraph (BasicBlock id ss : other_blocks)) =
         mkStmts (last : []) = mkLast last
         mkStmts []          = bad "fell off end"
         mkStmts (_ : _ : _) = bad "last node not at end"
         mkStmts (last : []) = mkLast last
         mkStmts []          = bad "fell off end"
         mkStmts (_ : _ : _) = bad "last node not at end"
-        bad msg = panic (msg {- ++ " in block " ++ showSDoc (ppr b) -}
-                            ++ " in function " ++ fun_name)
+        bad msg = pprPanic (msg ++ " in function " ++ fun_name) (ppr g)
         mkLast (CmmCall f  []     args _ CmmNeverReturns) = mkFinalCall f args
         mkLast (CmmSwitch scrutinee table) = mkSwitch scrutinee table
         mkLast (CmmJump tgt args)          = mkJump tgt args
         mkLast (CmmCall f  []     args _ CmmNeverReturns) = mkFinalCall f args
         mkLast (CmmSwitch scrutinee table) = mkSwitch scrutinee table
         mkLast (CmmJump tgt args)          = mkJump tgt args