Skip to content

-ddump-cmm -dsuppress-uniques is insufficient to eliminate noise in CMM diffs

-dsuppress-uniques does eliminate some noise, but not all. For example, labels in goto-statements, names of info_tbls and names of string literals are preserved. To allow effective diffing, these labels and names should be suppressed too.

Example:

-- a.hs

module M where

f (Just a) b = a + b
-- b.hs

module M where

f (Just a) b = a + b

g a b = a - b

Diff of ghc-9.2.2 -ddump-cmm -dsuppress-uniques output:

 ==================== Output Cmm ====================
 [section ""cstring" . $trModule3_bytes" {
@@ -46,16 +46,52 @@
 
 
 ==================== Output Cmm ====================
-[section ""cstring" . cBy_str" {
-     cBy_str:
-         I8[] "a.hs:5:1-20|function f"
+[M.g_entry() { //  [R4, R3, R2]
+         { info_tbls: [(cBQ,
+                        label: M.g_info
+                        rep: HeapRep static { Fun {arity: 3 fun_type: ArgSpec 23} }
+                        srt: Nothing)]
+           stack_info: arg_space: 8
+         }
+     {offset
+       _lbl_: // global
+           __locVar_::P64 = R4;
+           __locVar_::P64 = R3;
+           __locVar_::P64 = R2;
+           if ((Sp + 8) - 32 < SpLim) (likely: False) goto cBR; else goto cBS;
+       _lbl_: // global
+           R4 = __locVar_::P64;
+           R3 = __locVar_::P64;
+           R2 = __locVar_::P64;
+           R1 = M.g_closure;
+           call (stg_gc_fun)(R4, R3, R2, R1) args: 8, res: 0, upd: 8;
+       _lbl_: // global
+           R2 = __locVar_::P64;
+           I64[Sp - 24] = stg_ap_pp_info;
+           P64[Sp - 16] = __locVar_::P64;
+           P64[Sp - 8] = __locVar_::P64;
+           Sp = Sp - 24;
+           call GHC.Num.-_info(R2) args: 32, res: 0, upd: 8;
+     }
+ },
+ section ""data" . M.g_closure" {
+     M.g_closure:
+         const M.g_info;
+ }]
+
+
+
+==================== Output Cmm ====================
+[section ""cstring" . cCd_str" {
+     cCd_str:
+         I8[] "b.hs:5:1-20|function f"
  },
  M.f_entry() { //  [R4, R3, R2]
-         { info_tbls: [(cBm,
+         { info_tbls: [(cC1,
                         label: block_info
                         rep: StackRep [False, False]
                         srt: Just Control.Exception.Base.patError_closure),
-                       (cBt,
+                       (cC8,
                         label: M.f_info
                         rep: HeapRep static { Fun {arity: 3 fun_type: ArgSpec 23} }
                         srt: Just Control.Exception.Base.patError_closure)]
@@ -66,7 +102,7 @@
            __locVar_::P64 = R4;
            __locVar_::P64 = R3;
            __locVar_::P64 = R2;
-           if ((Sp + 8) - 32 < SpLim) (likely: False) goto cBu; else goto cBv;
+           if ((Sp + 8) - 32 < SpLim) (likely: False) goto cC9; else goto cCa;
        _lbl_: // global
            R4 = __locVar_::P64;
            R3 = __locVar_::P64;
@@ -74,19 +110,19 @@
            R1 = M.f_closure;
            call (stg_gc_fun)(R4, R3, R2, R1) args: 8, res: 0, upd: 8;
        _lbl_: // global
-           I64[Sp - 24] = cBm;
+           I64[Sp - 24] = cC1;
            R1 = __locVar_::P64;
            P64[Sp - 16] = __locVar_::P64;
            P64[Sp - 8] = __locVar_::P64;
            Sp = Sp - 24;
-           if (R1 & 7 != 0) goto cBm; else goto cBn;
+           if (R1 & 7 != 0) goto cC1; else goto cC2;
        _lbl_: // global
-           call (I64[R1])(R1) returns to cBm, args: 8, res: 8, upd: 8;
+           call (I64[R1])(R1) returns to cC1, args: 8, res: 8, upd: 8;
        _lbl_: // global
            __locVar_::P64 = P64[Sp + 8];
            __locVar_::P64 = R1;
            __locVar_::P64 = __locVar_::P64 & 7;
-           if (__locVar_::P64 != 1) goto cBr; else goto cBq;
+           if (__locVar_::P64 != 1) goto cC6; else goto cC5;
        _lbl_: // global
            __locVar_::P64 = P64[__locVar_::P64 + 6];
            R2 = __locVar_::P64;
@@ -94,7 +130,7 @@
            P64[Sp + 8] = __locVar_::P64;
            call GHC.Num.+_info(R2) args: 32, res: 0, upd: 8;
        _lbl_: // global
-           R2 = cBy_str;
+           R2 = cCd_str;
            Sp = Sp + 24;
            call Control.Exception.Base.patError_info(R2) args: 8, res: 0, upd: 8;
      }

The diff should be limited to the addition of g_entry. Any code related to f should be unchanged.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information