[PowerPC] Do not emit record-form rotates when record-form andi/andis suffices
[llvm-core.git] / lib / XRay / BlockIndexer.cpp
blob98e91f7de5487d0ce44627af24238a926ae93452
1 //===- BlockIndexer.cpp - FDR Block Indexing VIsitor ----------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // An implementation of the RecordVisitor which generates a mapping between a
11 // thread and a range of records representing a block.
13 //===----------------------------------------------------------------------===//
14 #include "llvm/XRay/BlockIndexer.h"
16 namespace llvm {
17 namespace xray {
19 Error BlockIndexer::visit(BufferExtents &) { return Error::success(); }
21 Error BlockIndexer::visit(WallclockRecord &R) {
22 CurrentBlock.Records.push_back(&R);
23 CurrentBlock.WallclockTime = &R;
24 return Error::success();
27 Error BlockIndexer::visit(NewCPUIDRecord &R) {
28 CurrentBlock.Records.push_back(&R);
29 return Error::success();
32 Error BlockIndexer::visit(TSCWrapRecord &R) {
33 CurrentBlock.Records.push_back(&R);
34 return Error::success();
37 Error BlockIndexer::visit(CustomEventRecord &R) {
38 CurrentBlock.Records.push_back(&R);
39 return Error::success();
42 Error BlockIndexer::visit(CallArgRecord &R) {
43 CurrentBlock.Records.push_back(&R);
44 return Error::success();
47 Error BlockIndexer::visit(PIDRecord &R) {
48 CurrentBlock.ProcessID = R.pid();
49 CurrentBlock.Records.push_back(&R);
50 return Error::success();
53 Error BlockIndexer::visit(NewBufferRecord &R) {
54 if (!CurrentBlock.Records.empty())
55 if (auto E = flush())
56 return E;
58 CurrentBlock.ThreadID = R.tid();
59 CurrentBlock.Records.push_back(&R);
60 return Error::success();
63 Error BlockIndexer::visit(EndBufferRecord &R) {
64 CurrentBlock.Records.push_back(&R);
65 return Error::success();
68 Error BlockIndexer::visit(FunctionRecord &R) {
69 CurrentBlock.Records.push_back(&R);
70 return Error::success();
73 Error BlockIndexer::flush() {
74 Index::iterator It;
75 std::tie(It, std::ignore) =
76 Indices.insert({{CurrentBlock.ProcessID, CurrentBlock.ThreadID}, {}});
77 It->second.push_back({CurrentBlock.ProcessID, CurrentBlock.ThreadID,
78 CurrentBlock.WallclockTime,
79 std::move(CurrentBlock.Records)});
80 CurrentBlock.ProcessID = 0;
81 CurrentBlock.ThreadID = 0;
82 CurrentBlock.Records = {};
83 CurrentBlock.WallclockTime = nullptr;
84 return Error::success();
87 } // namespace xray
88 } // namespace llvm