summaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm16/lib/XRay/FDRTraceExpander.cpp
diff options
context:
space:
mode:
authorvvvv <[email protected]>2024-02-06 20:01:22 +0300
committervvvv <[email protected]>2024-02-06 20:22:16 +0300
commit0203b7a9a40828bb2bd4c32029b79ff0ea3d1f8f (patch)
treee630d0d5bd0bd29fc8c2d2842ed2cfde781b993a /contrib/libs/llvm16/lib/XRay/FDRTraceExpander.cpp
parentba27db76d99d12a4f1c06960b5449423218614c4 (diff)
llvm16 targets
Diffstat (limited to 'contrib/libs/llvm16/lib/XRay/FDRTraceExpander.cpp')
-rw-r--r--contrib/libs/llvm16/lib/XRay/FDRTraceExpander.cpp131
1 files changed, 131 insertions, 0 deletions
diff --git a/contrib/libs/llvm16/lib/XRay/FDRTraceExpander.cpp b/contrib/libs/llvm16/lib/XRay/FDRTraceExpander.cpp
new file mode 100644
index 00000000000..b68e997fe70
--- /dev/null
+++ b/contrib/libs/llvm16/lib/XRay/FDRTraceExpander.cpp
@@ -0,0 +1,131 @@
+//===- FDRTraceExpander.cpp -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#include "llvm/XRay/FDRTraceExpander.h"
+
+namespace llvm {
+namespace xray {
+
+void TraceExpander::resetCurrentRecord() {
+ if (BuildingRecord)
+ C(CurrentRecord);
+ BuildingRecord = false;
+ CurrentRecord.CallArgs.clear();
+ CurrentRecord.Data.clear();
+}
+
+Error TraceExpander::visit(BufferExtents &) {
+ resetCurrentRecord();
+ return Error::success();
+}
+
+Error TraceExpander::visit(WallclockRecord &) { return Error::success(); }
+
+Error TraceExpander::visit(NewCPUIDRecord &R) {
+ CPUId = R.cpuid();
+ BaseTSC = R.tsc();
+ return Error::success();
+}
+
+Error TraceExpander::visit(TSCWrapRecord &R) {
+ BaseTSC = R.tsc();
+ return Error::success();
+}
+
+Error TraceExpander::visit(CustomEventRecord &R) {
+ resetCurrentRecord();
+ if (!IgnoringRecords) {
+ CurrentRecord.TSC = R.tsc();
+ CurrentRecord.CPU = R.cpu();
+ CurrentRecord.PId = PID;
+ CurrentRecord.TId = TID;
+ CurrentRecord.Type = RecordTypes::CUSTOM_EVENT;
+ CurrentRecord.Data = std::string(R.data());
+ BuildingRecord = true;
+ }
+ return Error::success();
+}
+
+Error TraceExpander::visit(CustomEventRecordV5 &R) {
+ resetCurrentRecord();
+ if (!IgnoringRecords) {
+ BaseTSC += R.delta();
+ CurrentRecord.TSC = BaseTSC;
+ CurrentRecord.CPU = CPUId;
+ CurrentRecord.PId = PID;
+ CurrentRecord.TId = TID;
+ CurrentRecord.Type = RecordTypes::CUSTOM_EVENT;
+ CurrentRecord.Data = std::string(R.data());
+ BuildingRecord = true;
+ }
+ return Error::success();
+}
+
+Error TraceExpander::visit(TypedEventRecord &R) {
+ resetCurrentRecord();
+ if (!IgnoringRecords) {
+ BaseTSC += R.delta();
+ CurrentRecord.TSC = BaseTSC;
+ CurrentRecord.CPU = CPUId;
+ CurrentRecord.PId = PID;
+ CurrentRecord.TId = TID;
+ CurrentRecord.RecordType = R.eventType();
+ CurrentRecord.Type = RecordTypes::TYPED_EVENT;
+ CurrentRecord.Data = std::string(R.data());
+ BuildingRecord = true;
+ }
+ return Error::success();
+}
+
+Error TraceExpander::visit(CallArgRecord &R) {
+ CurrentRecord.CallArgs.push_back(R.arg());
+ CurrentRecord.Type = RecordTypes::ENTER_ARG;
+ return Error::success();
+}
+
+Error TraceExpander::visit(PIDRecord &R) {
+ PID = R.pid();
+ return Error::success();
+}
+
+Error TraceExpander::visit(NewBufferRecord &R) {
+ if (IgnoringRecords)
+ IgnoringRecords = false;
+ TID = R.tid();
+ if (LogVersion == 2)
+ PID = R.tid();
+ return Error::success();
+}
+
+Error TraceExpander::visit(EndBufferRecord &) {
+ IgnoringRecords = true;
+ resetCurrentRecord();
+ return Error::success();
+}
+
+Error TraceExpander::visit(FunctionRecord &R) {
+ resetCurrentRecord();
+ if (!IgnoringRecords) {
+ BaseTSC += R.delta();
+ CurrentRecord.Type = R.recordType();
+ CurrentRecord.FuncId = R.functionId();
+ CurrentRecord.TSC = BaseTSC;
+ CurrentRecord.PId = PID;
+ CurrentRecord.TId = TID;
+ CurrentRecord.CPU = CPUId;
+ BuildingRecord = true;
+ }
+ return Error::success();
+}
+
+Error TraceExpander::flush() {
+ resetCurrentRecord();
+ return Error::success();
+}
+
+} // namespace xray
+} // namespace llvm