Skip to content

Commit 4cfbe55

Browse files
authored
[NFC][MemProf] Move types shared between Analysis, ProfileData and ModuleSummary (Core) to a separate header (llvm#140505)
Part of a larger refactoring with the following goals 1. Reduce the size of MemProf.h 2. Avoid including ModuleSummaryIndex just for a couple of types
1 parent ad45031 commit 4cfbe55

File tree

5 files changed

+47
-23
lines changed

5 files changed

+47
-23
lines changed

llvm/include/llvm/Analysis/MemoryProfileInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#ifndef LLVM_ANALYSIS_MEMORYPROFILEINFO_H
1414
#define LLVM_ANALYSIS_MEMORYPROFILEINFO_H
1515

16+
#include "llvm/IR/InstrTypes.h"
1617
#include "llvm/IR/Metadata.h"
17-
#include "llvm/IR/ModuleSummaryIndex.h"
18+
#include "llvm/ProfileData/MemProfCommon.h"
1819
#include <map>
1920

2021
namespace llvm {

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "llvm/IR/ConstantRange.h"
2828
#include "llvm/IR/GlobalValue.h"
2929
#include "llvm/IR/Module.h"
30+
#include "llvm/ProfileData/MemProfCommon.h"
3031
#include "llvm/Support/Allocator.h"
3132
#include "llvm/Support/Compiler.h"
3233
#include "llvm/Support/InterleavedRange.h"
@@ -306,14 +307,6 @@ template <> struct DenseMapInfo<ValueInfo> {
306307
static unsigned getHashValue(ValueInfo I) { return hash_value(I.getRef()); }
307308
};
308309

309-
// For optional hinted size reporting, holds a pair of the full stack id
310-
// (pre-trimming, from the full context in the profile), and the associated
311-
// total profiled size.
312-
struct ContextTotalSize {
313-
uint64_t FullStackId;
314-
uint64_t TotalSize;
315-
};
316-
317310
/// Summary of memprof callsite metadata.
318311
struct CallsiteInfo {
319312
// Actual callee function.
@@ -350,19 +343,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, const CallsiteInfo &SNI) {
350343
return OS;
351344
}
352345

353-
// Allocation type assigned to an allocation reached by a given context.
354-
// More can be added, now this is cold, notcold and hot.
355-
// Values should be powers of two so that they can be ORed, in particular to
356-
// track allocations that have different behavior with different calling
357-
// contexts.
358-
enum class AllocationType : uint8_t {
359-
None = 0,
360-
NotCold = 1,
361-
Cold = 2,
362-
Hot = 4,
363-
All = 7 // This should always be set to the OR of all values.
364-
};
365-
366346
/// Summary of a single MIB in a memprof metadata on allocations.
367347
struct MIBInfo {
368348
// The allocation type for this profiled context.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//===- MemProfCommon.h - MemProf support ----------------*- 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+
// This file contains common types used by different parts of the MemProf code.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_PROFILEDATA_MEMPROFCOMMON_H
14+
#define LLVM_PROFILEDATA_MEMPROFCOMMON_H
15+
16+
#include <cstdint>
17+
18+
namespace llvm {
19+
20+
// For optional hinted size reporting, holds a pair of the full stack id
21+
// (pre-trimming, from the full context in the profile), and the associated
22+
// total profiled size.
23+
struct ContextTotalSize {
24+
uint64_t FullStackId;
25+
uint64_t TotalSize;
26+
};
27+
28+
// Allocation type assigned to an allocation reached by a given context.
29+
// More can be added, now this is cold, notcold and hot.
30+
// Values should be powers of two so that they can be ORed, in particular to
31+
// track allocations that have different behavior with different calling
32+
// contexts.
33+
enum class AllocationType : uint8_t {
34+
None = 0,
35+
NotCold = 1,
36+
Cold = 2,
37+
Hot = 4,
38+
All = 7 // This should always be set to the OR of all values.
39+
};
40+
41+
} // namespace llvm
42+
43+
#endif // LLVM_PROFILEDATA_MEMPROFCOMMON_H

llvm/lib/ProfileData/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ add_llvm_component_library(LLVMProfileData
2626

2727
LINK_COMPONENTS
2828
BitstreamReader
29-
Core
3029
Object
3130
Support
3231
Demangle

llvm/lib/Transforms/Instrumentation/MemProfiler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "llvm/Transforms/Utils/ModuleUtils.h"
4747
#include <map>
4848
#include <set>
49+
#include <unordered_set>
4950

5051
using namespace llvm;
5152
using namespace llvm::memprof;

0 commit comments

Comments
 (0)