1 //===- BlockIndexer.h - FDR Block Indexing Visitor ------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // An implementation of the RecordVisitor which generates a mapping between a
11 // thread and a range of records representing a block.
13 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_XRAY_BLOCKINDEXER_H_
15 #define LLVM_LIB_XRAY_BLOCKINDEXER_H_
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/XRay/FDRRecords.h"
25 // The BlockIndexer will gather all related records associated with a
26 // process+thread and group them by 'Block'.
27 class BlockIndexer : public RecordVisitor {
32 WallclockRecord *WallclockTime;
33 std::vector<Record *> Records;
36 // This maps the process + thread combination to a sequence of blocks.
37 using Index = DenseMap<std::pair<uint64_t, int32_t>, std::vector<Block>>;
42 Block CurrentBlock{0, 0, nullptr, {}};
45 explicit BlockIndexer(Index &I) : RecordVisitor(), Indices(I) {}
47 Error visit(BufferExtents &) override;
48 Error visit(WallclockRecord &) override;
49 Error visit(NewCPUIDRecord &) override;
50 Error visit(TSCWrapRecord &) override;
51 Error visit(CustomEventRecord &) override;
52 Error visit(CallArgRecord &) override;
53 Error visit(PIDRecord &) override;
54 Error visit(NewBufferRecord &) override;
55 Error visit(EndBufferRecord &) override;
56 Error visit(FunctionRecord &) override;
57 Error visit(CustomEventRecordV5 &) override;
58 Error visit(TypedEventRecord &) override;
60 /// The flush() function will clear out the current state of the visitor, to
61 /// allow for explicitly flushing a block's records to the currently
62 /// recognized thread and process combination.
69 #endif // LLVM_LIB_XRAY_BLOCKINDEXER_H_