LLVM  8.0.1
BlockIndexer.cpp
Go to the documentation of this file.
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.
12 //
13 //===----------------------------------------------------------------------===//
14 #include "llvm/XRay/BlockIndexer.h"
15 
16 namespace llvm {
17 namespace xray {
18 
20 
22  CurrentBlock.Records.push_back(&R);
23  CurrentBlock.WallclockTime = &R;
24  return Error::success();
25 }
26 
28  CurrentBlock.Records.push_back(&R);
29  return Error::success();
30 }
31 
33  CurrentBlock.Records.push_back(&R);
34  return Error::success();
35 }
36 
38  CurrentBlock.Records.push_back(&R);
39  return Error::success();
40 }
41 
43  CurrentBlock.Records.push_back(&R);
44  return Error::success();
45 }
46 
48  CurrentBlock.Records.push_back(&R);
49  return Error::success();
50 }
51 
53  CurrentBlock.Records.push_back(&R);
54  return Error::success();
55 }
56 
58  CurrentBlock.ProcessID = R.pid();
59  CurrentBlock.Records.push_back(&R);
60  return Error::success();
61 }
62 
64  if (!CurrentBlock.Records.empty())
65  if (auto E = flush())
66  return E;
67 
68  CurrentBlock.ThreadID = R.tid();
69  CurrentBlock.Records.push_back(&R);
70  return Error::success();
71 }
72 
74  CurrentBlock.Records.push_back(&R);
75  return Error::success();
76 }
77 
79  CurrentBlock.Records.push_back(&R);
80  return Error::success();
81 }
82 
84  Index::iterator It;
85  std::tie(It, std::ignore) =
86  Indices.insert({{CurrentBlock.ProcessID, CurrentBlock.ThreadID}, {}});
87  It->second.push_back({CurrentBlock.ProcessID, CurrentBlock.ThreadID,
88  CurrentBlock.WallclockTime,
89  std::move(CurrentBlock.Records)});
90  CurrentBlock.ProcessID = 0;
91  CurrentBlock.ThreadID = 0;
92  CurrentBlock.Records = {};
93  CurrentBlock.WallclockTime = nullptr;
94  return Error::success();
95 }
96 
97 } // namespace xray
98 } // namespace llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:24
WallclockRecord * WallclockTime
Definition: BlockIndexer.h:32
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:221
int32_t pid() const
Definition: FDRRecords.h:328
Error visit(BufferExtents &) override
std::vector< Record * > Records
Definition: BlockIndexer.h:33
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static ErrorSuccess success()
Create a success value.
Definition: Error.h:327
Error flush()
The flush() function will clear out the current state of the visitor, to allow for explicitly flushin...
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158