FIX biographical profiling (#3039, probably #2297)
[ghc-hetmet.git] / includes / Cmm.h
index 06a66a7..da0a2ac 100644 (file)
    Indirections can contain tagged pointers, so their tag is checked.
    -------------------------------------------------------------------------- */
 
+#ifdef PROFILING
+
+// When profiling, we cannot shortcut ENTER() by checking the tag,
+// because LDV profiling relies on entering closures to mark them as
+// "used".
+
+#define LOAD_INFO \
+    info = %INFO_PTR(UNTAG(P1));
+
+#define UNTAG_R1 \
+    P1 = UNTAG(P1);
+
+#else
+
+#define LOAD_INFO                               \
+  if (GETTAG(P1) != 0) {                        \
+      jump %ENTRY_CODE(Sp(0));                  \
+  }                                             \
+  info = %INFO_PTR(P1);
+
+#define UNTAG_R1 /* nothing */
+
+#endif
+
 #define ENTER()                                                \
  again:                                                        \
   W_ info;                                             \
-  if (GETTAG(P1) != 0) {                                \
-      jump %ENTRY_CODE(Sp(0));                         \
-  }                                                     \
-  info = %INFO_PTR(P1);                                        \
+  LOAD_INFO                                             \
   switch [INVALID_OBJECT .. N_CLOSURE_TYPES]           \
          (TO_W_( %INFO_TYPE(%STD_INFO(info)) )) {      \
   case                                                 \
    }                                                   \
   default:                                             \
    {                                                   \
+      UNTAG_R1                                          \
       jump %ENTRY_CODE(info);                          \
    }                                                   \
   }