Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:45

0001 //===- BlockIndexer.h - FDR Block Indexing Visitor ------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // An implementation of the RecordVisitor which generates a mapping between a
0010 // thread and a range of records representing a block.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 #ifndef LLVM_XRAY_BLOCKINDEXER_H
0014 #define LLVM_XRAY_BLOCKINDEXER_H
0015 
0016 #include "llvm/ADT/DenseMap.h"
0017 #include "llvm/XRay/FDRRecords.h"
0018 #include <cstdint>
0019 #include <vector>
0020 
0021 namespace llvm {
0022 namespace xray {
0023 
0024 // The BlockIndexer will gather all related records associated with a
0025 // process+thread and group them by 'Block'.
0026 class BlockIndexer : public RecordVisitor {
0027 public:
0028   struct Block {
0029     uint64_t ProcessID;
0030     int32_t ThreadID;
0031     WallclockRecord *WallclockTime;
0032     std::vector<Record *> Records;
0033   };
0034 
0035   // This maps the process + thread combination to a sequence of blocks.
0036   using Index = DenseMap<std::pair<uint64_t, int32_t>, std::vector<Block>>;
0037 
0038 private:
0039   Index &Indices;
0040 
0041   Block CurrentBlock{0, 0, nullptr, {}};
0042 
0043 public:
0044   explicit BlockIndexer(Index &I) : Indices(I) {}
0045 
0046   Error visit(BufferExtents &) override;
0047   Error visit(WallclockRecord &) override;
0048   Error visit(NewCPUIDRecord &) override;
0049   Error visit(TSCWrapRecord &) override;
0050   Error visit(CustomEventRecord &) override;
0051   Error visit(CallArgRecord &) override;
0052   Error visit(PIDRecord &) override;
0053   Error visit(NewBufferRecord &) override;
0054   Error visit(EndBufferRecord &) override;
0055   Error visit(FunctionRecord &) override;
0056   Error visit(CustomEventRecordV5 &) override;
0057   Error visit(TypedEventRecord &) override;
0058 
0059   /// The flush() function will clear out the current state of the visitor, to
0060   /// allow for explicitly flushing a block's records to the currently
0061   /// recognized thread and process combination.
0062   Error flush();
0063 };
0064 
0065 } // namespace xray
0066 } // namespace llvm
0067 
0068 #endif // LLVM_XRAY_BLOCKINDEXER_H