Skip to content

Commit 9c1366d

Browse files
committed
[llvm] manual fix-ups to IDS codemod of ProfileData library
1 parent c91feb3 commit 9c1366d

File tree

6 files changed

+32
-24
lines changed

6 files changed

+32
-24
lines changed

llvm/include/llvm/ProfileData/InstrProfData.inc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,14 @@ typedef struct ValueProfRecord {
405405
/*!
406406
* Read data from this record and save it to Record.
407407
*/
408-
void deserializeTo(InstrProfRecord &Record,
408+
LLVM_ABI void deserializeTo(InstrProfRecord &Record,
409409
InstrProfSymtab *SymTab);
410410
/*
411411
* In-place byte swap:
412412
* Do byte swap for this instance. \c Old is the original order before
413413
* the swap, and \c New is the New byte order.
414414
*/
415-
void swapBytes(llvm::endianness Old, llvm::endianness New);
415+
LLVM_ABI void swapBytes(llvm::endianness Old, llvm::endianness New);
416416
#endif
417417
} ValueProfRecord;
418418

@@ -449,41 +449,41 @@ typedef struct ValueProfData {
449449
* Return the total size in bytes of the on-disk value profile data
450450
* given the data stored in Record.
451451
*/
452-
static uint32_t getSize(const InstrProfRecord &Record);
452+
LLVM_ABI static uint32_t getSize(const InstrProfRecord &Record);
453453
/*!
454454
* Return a pointer to \c ValueProfData instance ready to be streamed.
455455
*/
456-
static std::unique_ptr<ValueProfData>
456+
LLVM_ABI static std::unique_ptr<ValueProfData>
457457
serializeFrom(const InstrProfRecord &Record);
458458
/*!
459459
* Check the integrity of the record.
460460
*/
461-
Error checkIntegrity();
461+
LLVM_ABI Error checkIntegrity();
462462
/*!
463463
* Return a pointer to \c ValueProfileData instance ready to be read.
464464
* All data in the instance are properly byte swapped. The input
465465
* data is assumed to be in little endian order.
466466
*/
467-
static Expected<std::unique_ptr<ValueProfData>>
467+
LLVM_ABI static Expected<std::unique_ptr<ValueProfData>>
468468
getValueProfData(const unsigned char *SrcBuffer,
469469
const unsigned char *const SrcBufferEnd,
470470
llvm::endianness SrcDataEndianness);
471471
/*!
472472
* Swap byte order from \c Endianness order to host byte order.
473473
*/
474-
void swapBytesToHost(llvm::endianness Endianness);
474+
LLVM_ABI void swapBytesToHost(llvm::endianness Endianness);
475475
/*!
476476
* Swap byte order from host byte order to \c Endianness order.
477477
*/
478-
void swapBytesFromHost(llvm::endianness Endianness);
478+
LLVM_ABI void swapBytesFromHost(llvm::endianness Endianness);
479479
/*!
480480
* Return the total size of \c ValueProfileData.
481481
*/
482-
uint32_t getSize() const { return TotalSize; }
482+
LLVM_ABI uint32_t getSize() const { return TotalSize; }
483483
/*!
484484
* Read data from this data and save it to \c Record.
485485
*/
486-
void deserializeTo(InstrProfRecord &Record,
486+
LLVM_ABI void deserializeTo(InstrProfRecord &Record,
487487
InstrProfSymtab *SymTab);
488488
void operator delete(void *ptr) { ::operator delete(ptr); }
489489
#endif

llvm/include/llvm/ProfileData/MemProfRadixTree.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "llvm/ProfileData/IndexedMemProfData.h"
1717
#include "llvm/ProfileData/MemProf.h"
18+
#include "llvm/Support/Compiler.h"
1819

1920
namespace llvm {
2021
namespace memprof {
@@ -353,6 +354,11 @@ template <typename FrameIdTy> class CallStackRadixTreeBuilder {
353354
return std::move(CallStackPos);
354355
}
355356
};
357+
358+
// Defined in MemProfRadixTree.cpp
359+
extern template class LLVM_TEMPLATE_ABI CallStackRadixTreeBuilder<FrameId>;
360+
extern template class LLVM_TEMPLATE_ABI CallStackRadixTreeBuilder<LinearFrameId>;
361+
356362
} // namespace memprof
357363
} // namespace llvm
358364
#endif // LLVM_PROFILEDATA_MEMPROFRADIXTREE_H

llvm/include/llvm/ProfileData/SampleProfWriter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class LLVM_ABI SampleProfileWriterText : public SampleProfileWriter {
193193
/// cannot be skipped.
194194
bool MarkFlatProfiles = false;
195195

196-
friend ErrorOr<std::unique_ptr<SampleProfileWriter>>
196+
LLVM_ABI_FRIEND friend ErrorOr<std::unique_ptr<SampleProfileWriter>>
197197
SampleProfileWriter::create(std::unique_ptr<raw_ostream> &OS,
198198
SampleProfileFormat Format);
199199
};
@@ -225,7 +225,7 @@ class LLVM_ABI SampleProfileWriterBinary : public SampleProfileWriter {
225225
void addNames(const FunctionSamples &S);
226226

227227
private:
228-
friend ErrorOr<std::unique_ptr<SampleProfileWriter>>
228+
LLVM_ABI_FRIEND friend ErrorOr<std::unique_ptr<SampleProfileWriter>>
229229
SampleProfileWriter::create(std::unique_ptr<raw_ostream> &OS,
230230
SampleProfileFormat Format);
231231
};

llvm/lib/ProfileData/MemProfCommon.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,36 @@
1414
#include "llvm/ProfileData/MemProf.h"
1515
#include "llvm/Support/BLAKE3.h"
1616
#include "llvm/Support/CommandLine.h"
17+
#include "llvm/Support/Compiler.h"
1718
#include "llvm/Support/HashBuilder.h"
1819

1920
using namespace llvm;
2021
using namespace llvm::memprof;
2122

2223
// Upper bound on lifetime access density (accesses per byte per lifetime sec)
2324
// for marking an allocation cold.
24-
cl::opt<float> MemProfLifetimeAccessDensityColdThreshold(
25+
LLVM_ABI cl::opt<float> MemProfLifetimeAccessDensityColdThreshold(
2526
"memprof-lifetime-access-density-cold-threshold", cl::init(0.05),
2627
cl::Hidden,
2728
cl::desc("The threshold the lifetime access density (accesses per byte per "
2829
"lifetime sec) must be under to consider an allocation cold"));
2930

3031
// Lower bound on lifetime to mark an allocation cold (in addition to accesses
3132
// per byte per sec above). This is to avoid pessimizing short lived objects.
32-
cl::opt<unsigned> MemProfAveLifetimeColdThreshold(
33+
LLVM_ABI cl::opt<unsigned> MemProfAveLifetimeColdThreshold(
3334
"memprof-ave-lifetime-cold-threshold", cl::init(200), cl::Hidden,
3435
cl::desc("The average lifetime (s) for an allocation to be considered "
3536
"cold"));
3637

3738
// Lower bound on average lifetime accesses density (total life time access
3839
// density / alloc count) for marking an allocation hot.
39-
cl::opt<unsigned> MemProfMinAveLifetimeAccessDensityHotThreshold(
40+
LLVM_ABI cl::opt<unsigned> MemProfMinAveLifetimeAccessDensityHotThreshold(
4041
"memprof-min-ave-lifetime-access-density-hot-threshold", cl::init(1000),
4142
cl::Hidden,
4243
cl::desc("The minimum TotalLifetimeAccessDensity / AllocCount for an "
4344
"allocation to be considered hot"));
4445

45-
cl::opt<bool>
46+
LLVM_ABI cl::opt<bool>
4647
MemProfUseHotHints("memprof-use-hot-hints", cl::init(false), cl::Hidden,
4748
cl::desc("Enable use of hot hints (only supported for "
4849
"unambigously hot allocations)"));

llvm/lib/ProfileData/MemProfRadixTree.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ void CallStackRadixTreeBuilder<FrameIdTy>::build(
220220
}
221221

222222
// Explicitly instantiate class with the utilized FrameIdTy.
223-
template class CallStackRadixTreeBuilder<FrameId>;
224-
template class CallStackRadixTreeBuilder<LinearFrameId>;
223+
template class LLVM_EXPORT_TEMPLATE CallStackRadixTreeBuilder<FrameId>;
224+
template class LLVM_EXPORT_TEMPLATE CallStackRadixTreeBuilder<LinearFrameId>;
225225

226226
template <typename FrameIdTy>
227227
llvm::DenseMap<FrameIdTy, FrameStat>
@@ -241,11 +241,11 @@ computeFrameHistogram(llvm::MapVector<CallStackId, llvm::SmallVector<FrameIdTy>>
241241
}
242242

243243
// Explicitly instantiate function with the utilized FrameIdTy.
244-
template llvm::DenseMap<FrameId, FrameStat> computeFrameHistogram<FrameId>(
244+
template llvm::DenseMap<FrameId, FrameStat> LLVM_ABI computeFrameHistogram<FrameId>(
245245
llvm::MapVector<CallStackId, llvm::SmallVector<FrameId>>
246246
&MemProfCallStackData);
247247
template llvm::DenseMap<LinearFrameId, FrameStat>
248-
computeFrameHistogram<LinearFrameId>(
248+
LLVM_ABI computeFrameHistogram<LinearFrameId>(
249249
llvm::MapVector<CallStackId, llvm::SmallVector<LinearFrameId>>
250250
&MemProfCallStackData);
251251
} // namespace memprof

llvm/unittests/ProfileData/MemProfTest.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@
1919
#include "llvm/ProfileData/MemProfData.inc"
2020
#include "llvm/ProfileData/MemProfRadixTree.h"
2121
#include "llvm/ProfileData/MemProfReader.h"
22+
#include "llvm/Support/Compiler.h"
2223
#include "llvm/Support/raw_ostream.h"
2324
#include "gmock/gmock.h"
2425
#include "gtest/gtest.h"
2526

2627
#include <initializer_list>
2728

28-
extern llvm::cl::opt<float> MemProfLifetimeAccessDensityColdThreshold;
29-
extern llvm::cl::opt<unsigned> MemProfAveLifetimeColdThreshold;
30-
extern llvm::cl::opt<unsigned> MemProfMinAveLifetimeAccessDensityHotThreshold;
31-
extern llvm::cl::opt<bool> MemProfUseHotHints;
29+
LLVM_ABI extern llvm::cl::opt<float> MemProfLifetimeAccessDensityColdThreshold;
30+
LLVM_ABI extern llvm::cl::opt<unsigned> MemProfAveLifetimeColdThreshold;
31+
LLVM_ABI extern llvm::cl::opt<unsigned> MemProfMinAveLifetimeAccessDensityHotThreshold;
32+
LLVM_ABI extern llvm::cl::opt<bool> MemProfUseHotHints;
3233

3334
namespace llvm {
3435
namespace memprof {

0 commit comments

Comments
 (0)