[PATCH] D54292: [XRay] Fix enter function tracing for record unwriting

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 8 21:04:16 PST 2018


dberris created this revision.
dberris added a reviewer: mboerger.

Before this change, we could run into a situation where we may try to
undo tail exit records after writing metadata records before a function
enter event. This change rectifies that by resetting the tail exit
counter after writing the metadata records.


https://reviews.llvm.org/D54292

Files:
  compiler-rt/lib/xray/xray_fdr_controller.h


Index: compiler-rt/lib/xray/xray_fdr_controller.h
===================================================================
--- compiler-rt/lib/xray/xray_fdr_controller.h
+++ compiler-rt/lib/xray/xray_fdr_controller.h
@@ -252,9 +252,13 @@
     if (PreambleStatus == PreambleResult::InvalidBuffer)
       return returnBuffer();
 
-    UndoableFunctionEnters = (PreambleStatus == PreambleResult::WroteMetadata)
-                                 ? 1
-                                 : UndoableFunctionEnters + 1;
+    if (PreambleStatus == PreambleResult::WroteMetadata) {
+      UndoableFunctionEnters = 1;
+      UndoableTailExits = 0;
+    } else {
+      ++UndoableFunctionEnters;
+    }
+
     auto Delta = TSC - LatestTSC;
     LastFunctionEntryTSC = TSC;
     LatestTSC = TSC;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54292.173269.patch
Type: text/x-patch
Size: 776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181109/61a4ba47/attachment.bin>


More information about the llvm-commits mailing list