Skip to content

Commit d4d1ca9

Browse files
committed
[ORC][JITLink] Factor out common VTune data structures into OrcShared
Fixed the cyclic library dependency: llvm#83909
1 parent b892ab4 commit d4d1ca9

File tree

3 files changed

+105
-83
lines changed

3 files changed

+105
-83
lines changed

llvm/include/llvm/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.h

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
#include "llvm/ExecutionEngine/Orc/Core.h"
1717
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
18-
1918
#include "llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h"
19+
#include "llvm/ExecutionEngine/Orc/Shared/VTuneSharedStructs.h"
2020

2121
namespace llvm {
2222

@@ -57,87 +57,6 @@ class VTuneSupportPlugin : public ObjectLinkingLayer::Plugin {
5757
bool EmitDebugInfo;
5858
};
5959

60-
typedef std::vector<std::pair<unsigned, unsigned>> VTuneLineTable;
61-
62-
// SI = String Index, 1-indexed into the VTuneMethodBatch::Strings table.
63-
// SI == 0 means replace with nullptr.
64-
65-
// MI = Method Index, 1-indexed into the VTuneMethodBatch::Methods table.
66-
// MI == 0 means this is a parent method and was not inlined.
67-
68-
struct VTuneMethodInfo {
69-
VTuneLineTable LineTable;
70-
ExecutorAddr LoadAddr;
71-
uint64_t LoadSize;
72-
uint64_t MethodID;
73-
uint32_t NameSI;
74-
uint32_t ClassFileSI;
75-
uint32_t SourceFileSI;
76-
uint32_t ParentMI;
77-
};
78-
79-
typedef std::vector<VTuneMethodInfo> VTuneMethodTable;
80-
typedef std::vector<std::string> VTuneStringTable;
81-
82-
struct VTuneMethodBatch {
83-
VTuneMethodTable Methods;
84-
VTuneStringTable Strings;
85-
};
86-
87-
typedef std::vector<std::pair<uint64_t, uint64_t>> VTuneUnloadedMethodIDs;
88-
89-
namespace shared {
90-
91-
using SPSVTuneLineTable = SPSSequence<SPSTuple<uint32_t, uint32_t>>;
92-
using SPSVTuneMethodInfo =
93-
SPSTuple<SPSVTuneLineTable, SPSExecutorAddr, uint64_t, uint64_t, uint32_t,
94-
uint32_t, uint32_t, uint32_t>;
95-
using SPSVTuneMethodTable = SPSSequence<SPSVTuneMethodInfo>;
96-
using SPSVTuneStringTable = SPSSequence<SPSString>;
97-
using SPSVTuneMethodBatch = SPSTuple<SPSVTuneMethodTable, SPSVTuneStringTable>;
98-
using SPSVTuneUnloadedMethodIDs = SPSSequence<SPSTuple<uint64_t, uint64_t>>;
99-
100-
template <> class SPSSerializationTraits<SPSVTuneMethodInfo, VTuneMethodInfo> {
101-
public:
102-
static size_t size(const VTuneMethodInfo &MI) {
103-
return SPSVTuneMethodInfo::AsArgList::size(
104-
MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
105-
MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
106-
}
107-
108-
static bool deserialize(SPSInputBuffer &IB, VTuneMethodInfo &MI) {
109-
return SPSVTuneMethodInfo::AsArgList::deserialize(
110-
IB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
111-
MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
112-
}
113-
114-
static bool serialize(SPSOutputBuffer &OB, const VTuneMethodInfo &MI) {
115-
return SPSVTuneMethodInfo::AsArgList::serialize(
116-
OB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
117-
MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
118-
}
119-
};
120-
121-
template <>
122-
class SPSSerializationTraits<SPSVTuneMethodBatch, VTuneMethodBatch> {
123-
public:
124-
static size_t size(const VTuneMethodBatch &MB) {
125-
return SPSVTuneMethodBatch::AsArgList::size(MB.Methods, MB.Strings);
126-
}
127-
128-
static bool deserialize(SPSInputBuffer &IB, VTuneMethodBatch &MB) {
129-
return SPSVTuneMethodBatch::AsArgList::deserialize(IB, MB.Methods,
130-
MB.Strings);
131-
}
132-
133-
static bool serialize(SPSOutputBuffer &OB, const VTuneMethodBatch &MB) {
134-
return SPSVTuneMethodBatch::AsArgList::serialize(OB, MB.Methods,
135-
MB.Strings);
136-
}
137-
};
138-
139-
} // end namespace shared
140-
14160
} // end namespace orc
14261

14362
} // end namespace llvm
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
//===-------------------- VTuneSharedStructs.h ------------------*- C++ -*-===//
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+
// Structs and serialization to share VTune-related information
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H
14+
#define LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H
15+
16+
namespace llvm {
17+
namespace orc {
18+
19+
typedef std::vector<std::pair<unsigned, unsigned>> VTuneLineTable;
20+
21+
// SI = String Index, 1-indexed into the VTuneMethodBatch::Strings table.
22+
// SI == 0 means replace with nullptr.
23+
24+
// MI = Method Index, 1-indexed into the VTuneMethodBatch::Methods table.
25+
// MI == 0 means this is a parent method and was not inlined.
26+
27+
struct VTuneMethodInfo {
28+
VTuneLineTable LineTable;
29+
ExecutorAddr LoadAddr;
30+
uint64_t LoadSize;
31+
uint64_t MethodID;
32+
uint32_t NameSI;
33+
uint32_t ClassFileSI;
34+
uint32_t SourceFileSI;
35+
uint32_t ParentMI;
36+
};
37+
38+
typedef std::vector<VTuneMethodInfo> VTuneMethodTable;
39+
typedef std::vector<std::string> VTuneStringTable;
40+
41+
struct VTuneMethodBatch {
42+
VTuneMethodTable Methods;
43+
VTuneStringTable Strings;
44+
};
45+
46+
typedef std::vector<std::pair<uint64_t, uint64_t>> VTuneUnloadedMethodIDs;
47+
48+
namespace shared {
49+
50+
using SPSVTuneLineTable = SPSSequence<SPSTuple<uint32_t, uint32_t>>;
51+
using SPSVTuneMethodInfo =
52+
SPSTuple<SPSVTuneLineTable, SPSExecutorAddr, uint64_t, uint64_t, uint32_t,
53+
uint32_t, uint32_t, uint32_t>;
54+
using SPSVTuneMethodTable = SPSSequence<SPSVTuneMethodInfo>;
55+
using SPSVTuneStringTable = SPSSequence<SPSString>;
56+
using SPSVTuneMethodBatch = SPSTuple<SPSVTuneMethodTable, SPSVTuneStringTable>;
57+
using SPSVTuneUnloadedMethodIDs = SPSSequence<SPSTuple<uint64_t, uint64_t>>;
58+
59+
template <> class SPSSerializationTraits<SPSVTuneMethodInfo, VTuneMethodInfo> {
60+
public:
61+
static size_t size(const VTuneMethodInfo &MI) {
62+
return SPSVTuneMethodInfo::AsArgList::size(
63+
MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
64+
MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
65+
}
66+
67+
static bool deserialize(SPSInputBuffer &IB, VTuneMethodInfo &MI) {
68+
return SPSVTuneMethodInfo::AsArgList::deserialize(
69+
IB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
70+
MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
71+
}
72+
73+
static bool serialize(SPSOutputBuffer &OB, const VTuneMethodInfo &MI) {
74+
return SPSVTuneMethodInfo::AsArgList::serialize(
75+
OB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
76+
MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
77+
}
78+
};
79+
80+
template <>
81+
class SPSSerializationTraits<SPSVTuneMethodBatch, VTuneMethodBatch> {
82+
public:
83+
static size_t size(const VTuneMethodBatch &MB) {
84+
return SPSVTuneMethodBatch::AsArgList::size(MB.Methods, MB.Strings);
85+
}
86+
87+
static bool deserialize(SPSInputBuffer &IB, VTuneMethodBatch &MB) {
88+
return SPSVTuneMethodBatch::AsArgList::deserialize(IB, MB.Methods,
89+
MB.Strings);
90+
}
91+
92+
static bool serialize(SPSOutputBuffer &OB, const VTuneMethodBatch &MB) {
93+
return SPSVTuneMethodBatch::AsArgList::serialize(OB, MB.Methods,
94+
MB.Strings);
95+
}
96+
};
97+
98+
} // end namespace shared
99+
} // end namespace orc
100+
} // end namespace llvm
101+
102+
#endif

llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderVTune.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderVTune.h"
13-
#include "llvm/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.h"
13+
#include "llvm/ExecutionEngine/Orc/Shared/VTuneSharedStructs.h"
14+
#include <map>
1415

1516
#if LLVM_USE_INTEL_JITEVENTS
1617
#include "IntelJITEventsWrapper.h"

0 commit comments

Comments
 (0)