 +  if exists
 +    then do bh <- Bin.readBinMem hsSpliceFile
 +            getWithUserData ncu bh
-+    else panic (".hs-splice file does not exist: " ++ hsSpliceFile)
++    else pure emptyHsSpliceData
 +
 +writeHsSpliceData :: FilePath -> HsSpliceData -> TcM ()
-+writeHsSpliceData hsSpliceFile hs_splice_data = liftIO $ do
-+  bh <- Bin.openBinMem (100 * 1024) -- FIXME???
-+  putWithUserData (putStrLn . showSDocUnsafe) bh hs_splice_data
-+  Bin.writeBinMem bh hsSpliceFile
++writeHsSpliceData hsSpliceFile hsSpliceData =
++  when (nonEmptyHsSpliceData hsSpliceData) $ do
++    dflags <- getDynFlags
++    liftIO $ do
++      bh <- Bin.openBinMem (100 * 1024)
++      --  ^^^ FIXME: how should we compute an approximation of size?
++      putWithUserData (debugTraceMsg dflags 3) bh hsSpliceData
++      Bin.writeBinMem bh hsSpliceFile
 +
 +-- | Update the splice data from the TcGblEnv using the given
 +--   function. Used when -save-splices is passed, to record

          -> (SrcSpan -> ForeignHValue -> TcM (Either MsgDoc hs_syn))        -- How to run x
          -> LHsExpr GhcTc        -- Of type x; typically x = Q TH.Exp, or
                                  --    something like that
@@ -727,7 +812,7 @@ runMeta' show_code ppr_hs run_and_convert expr
                             -- we catch all kinds of splices and annotations.
 
         -- Check that we've had no errors of any sort so far.

+
 runMetaAW :: LHsExpr GhcTc         -- Of type AnnotationWrapper
           -> TcM Serialized
 runMetaAW = runMeta metaRequestAW
+  (panic "runMetaAW doesn't support splice caching (read)")
+  (panic "runMetaAW doesn't support splice caching (write)")
 
 runMetaE :: LHsExpr GhcTc          -- Of type (Q Exp)
          -> TcM (LHsExpr GhcPs)
