LLVM 22.0.0git
BlockIndexer.h
Go to the documentation of this file.
1//===- BlockIndexer.h - FDR Block Indexing Visitor ------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// An implementation of the RecordVisitor which generates a mapping between a
10// thread and a range of records representing a block.
11//
12//===----------------------------------------------------------------------===//
13#ifndef LLVM_XRAY_BLOCKINDEXER_H
14#define LLVM_XRAY_BLOCKINDEXER_H
15
16#include "llvm/ADT/DenseMap.h"
19#include <cstdint>
20#include <vector>
21
22namespace llvm {
23namespace xray {
24
25// The BlockIndexer will gather all related records associated with a
26// process+thread and group them by 'Block'.
28public:
29 struct Block {
31 int32_t ThreadID;
33 std::vector<Record *> Records;
34 };
35
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>>;
38
39private:
40 Index &Indices;
41
42 Block CurrentBlock{0, 0, nullptr, {}};
43
44public:
45 explicit BlockIndexer(Index &I) : Indices(I) {}
46
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;
58 Error visit(TypedEventRecord &) override;
59
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.
63 Error flush();
64};
65
66} // namespace xray
67} // namespace llvm
68
69#endif // LLVM_XRAY_BLOCKINDEXER_H
#define LLVM_ABI
Definition Compiler.h:213
This file defines the DenseMap class.
#define I(x, y, z)
Definition MD5.cpp:58
void visit(MachineFunction &MF, MachineBasicBlock &Start, std::function< void(MachineBasicBlock *)> op)
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
DenseMap< std::pair< uint64_t, int32_t >, std::vector< Block > > Index
This is an optimization pass for GlobalISel generic memory operations.
std::vector< Record * > Records
WallclockRecord * WallclockTime