Skip to content

Commit 39120a1

Browse files
committed
[llvm] export private API so that CodeGenTests builds against Windows DLL
1 parent 5f91d2f commit 39120a1

File tree

4 files changed

+46
-39
lines changed

4 files changed

+46
-39
lines changed

llvm/lib/CodeGen/AsmPrinter/DIEHash.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "llvm/ADT/DenseMap.h"
1717
#include "llvm/CodeGen/DIE.h"
18+
#include "llvm/Support/Compiler.h"
1819
#include "llvm/Support/MD5.h"
1920

2021
namespace llvm {
@@ -38,7 +39,7 @@ class DIEHash {
3839
uint64_t computeCUSignature(StringRef DWOName, const DIE &Die);
3940

4041
/// Computes the type signature.
41-
uint64_t computeTypeSignature(const DIE &Die);
42+
LLVM_ABI_FOR_TEST uint64_t computeTypeSignature(const DIE &Die);
4243

4344
// Helper routines to process parts of a DIE.
4445
private:

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/CodeGen/MachineInstr.h"
2020
#include "llvm/CodeGen/TargetRegisterInfo.h"
2121
#include "llvm/IR/DebugInfoMetadata.h"
22+
#include "llvm/Support/Compiler.h"
2223
#include <optional>
2324

2425
#include "LiveDebugValues.h"
@@ -204,8 +205,8 @@ class ValueIDNum {
204205
.str();
205206
}
206207

207-
static ValueIDNum EmptyValue;
208-
static ValueIDNum TombstoneValue;
208+
LLVM_ABI_FOR_TEST static ValueIDNum EmptyValue;
209+
LLVM_ABI_FOR_TEST static ValueIDNum TombstoneValue;
209210
};
210211

211212
} // End namespace LiveDebugValues
@@ -425,7 +426,7 @@ struct DbgOpID {
425426
DbgOpID(uint32_t RawID) : RawID(RawID) {}
426427
DbgOpID(bool IsConst, uint32_t Index) : ID({IsConst, Index}) {}
427428

428-
static DbgOpID UndefID;
429+
LLVM_ABI_FOR_TEST static DbgOpID UndefID;
429430

430431
bool operator==(const DbgOpID &Other) const { return RawID == Other.RawID; }
431432
bool operator!=(const DbgOpID &Other) const { return !(*this == Other); }
@@ -788,8 +789,9 @@ class MLocTracker {
788789
value_type operator*() { return value_type(Idx, ValueMap[LocIdx(Idx)]); }
789790
};
790791

791-
MLocTracker(MachineFunction &MF, const TargetInstrInfo &TII,
792-
const TargetRegisterInfo &TRI, const TargetLowering &TLI);
792+
LLVM_ABI_FOR_TEST MLocTracker(MachineFunction &MF, const TargetInstrInfo &TII,
793+
const TargetRegisterInfo &TRI,
794+
const TargetLowering &TLI);
793795

794796
/// Produce location ID number for a Register. Provides some small amount of
795797
/// type safety.
@@ -903,7 +905,7 @@ class MLocTracker {
903905

904906
/// Create a LocIdx for an untracked register ID. Initialize it to either an
905907
/// mphi value representing a live-in, or a recent register mask clobber.
906-
LocIdx trackRegister(unsigned ID);
908+
LLVM_ABI_FOR_TEST LocIdx trackRegister(unsigned ID);
907909

908910
LocIdx lookupOrTrackRegister(unsigned ID) {
909911
LocIdx &Index = LocIDToLocIdx[ID];
@@ -968,7 +970,8 @@ class MLocTracker {
968970
/// Find LocIdx for SpillLoc \p L, creating a new one if it's not tracked.
969971
/// Returns std::nullopt when in scenarios where a spill slot could be
970972
/// tracked, but we would likely run into resource limitations.
971-
std::optional<SpillLocationNo> getOrTrackSpillLoc(SpillLoc L);
973+
LLVM_ABI_FOR_TEST std::optional<SpillLocationNo>
974+
getOrTrackSpillLoc(SpillLoc L);
972975

973976
// Get LocIdx of a spill ID.
974977
LocIdx getSpillMLoc(unsigned SpillID) {
@@ -1342,7 +1345,7 @@ class InstrRefBasedLDV : public LDVImpl {
13421345
/// in an MLocTracker. Convert the observations into a per-block transfer
13431346
/// function in \p MLocTransfer, suitable for using with the machine value
13441347
/// location dataflow problem.
1345-
void
1348+
LLVM_ABI_FOR_TEST void
13461349
produceMLocTransferFunction(MachineFunction &MF,
13471350
SmallVectorImpl<MLocTransferMap> &MLocTransfer,
13481351
unsigned MaxNumBlocks);
@@ -1352,20 +1355,20 @@ class InstrRefBasedLDV : public LDVImpl {
13521355
/// live-out arrays to the (initialized to zero) multidimensional arrays in
13531356
/// \p MInLocs and \p MOutLocs. The outer dimension is indexed by block
13541357
/// number, the inner by LocIdx.
1355-
void buildMLocValueMap(MachineFunction &MF, FuncValueTable &MInLocs,
1356-
FuncValueTable &MOutLocs,
1357-
SmallVectorImpl<MLocTransferMap> &MLocTransfer);
1358+
LLVM_ABI_FOR_TEST void
1359+
buildMLocValueMap(MachineFunction &MF, FuncValueTable &MInLocs,
1360+
FuncValueTable &MOutLocs,
1361+
SmallVectorImpl<MLocTransferMap> &MLocTransfer);
13581362

13591363
/// Examine the stack indexes (i.e. offsets within the stack) to find the
13601364
/// basic units of interference -- like reg units, but for the stack.
13611365
void findStackIndexInterference(SmallVectorImpl<unsigned> &Slots);
13621366

13631367
/// Install PHI values into the live-in array for each block, according to
13641368
/// the IDF of each register.
1365-
void placeMLocPHIs(MachineFunction &MF,
1366-
SmallPtrSetImpl<MachineBasicBlock *> &AllBlocks,
1367-
FuncValueTable &MInLocs,
1368-
SmallVectorImpl<MLocTransferMap> &MLocTransfer);
1369+
LLVM_ABI_FOR_TEST void placeMLocPHIs(
1370+
MachineFunction &MF, SmallPtrSetImpl<MachineBasicBlock *> &AllBlocks,
1371+
FuncValueTable &MInLocs, SmallVectorImpl<MLocTransferMap> &MLocTransfer);
13691372

13701373
/// Propagate variable values to blocks in the common case where there's
13711374
/// only one value assigned to the variable. This function has better
@@ -1422,12 +1425,13 @@ class InstrRefBasedLDV : public LDVImpl {
14221425
/// \p AssignBlocks contains the set of blocks that aren't in \p DILoc's
14231426
/// scope, but which do contain DBG_VALUEs, which VarLocBasedImpl tracks
14241427
/// locations through.
1425-
void buildVLocValueMap(const DILocation *DILoc,
1426-
const SmallSet<DebugVariableID, 4> &VarsWeCareAbout,
1427-
SmallPtrSetImpl<MachineBasicBlock *> &AssignBlocks,
1428-
LiveInsT &Output, FuncValueTable &MOutLocs,
1429-
FuncValueTable &MInLocs,
1430-
SmallVectorImpl<VLocTracker> &AllTheVLocs);
1428+
LLVM_ABI_FOR_TEST void
1429+
buildVLocValueMap(const DILocation *DILoc,
1430+
const SmallSet<DebugVariableID, 4> &VarsWeCareAbout,
1431+
SmallPtrSetImpl<MachineBasicBlock *> &AssignBlocks,
1432+
LiveInsT &Output, FuncValueTable &MOutLocs,
1433+
FuncValueTable &MInLocs,
1434+
SmallVectorImpl<VLocTracker> &AllTheVLocs);
14311435

14321436
/// Attempt to eliminate un-necessary PHIs on entry to a block. Examines the
14331437
/// live-in values coming from predecessors live-outs, and replaces any PHIs
@@ -1436,16 +1440,17 @@ class InstrRefBasedLDV : public LDVImpl {
14361440
/// \p LiveIn Old live-in value, overwritten with new one if live-in changes.
14371441
/// \returns true if any live-ins change value, either from value propagation
14381442
/// or PHI elimination.
1439-
bool vlocJoin(MachineBasicBlock &MBB, LiveIdxT &VLOCOutLocs,
1440-
SmallPtrSet<const MachineBasicBlock *, 8> &BlocksToExplore,
1441-
DbgValue &LiveIn);
1443+
LLVM_ABI_FOR_TEST bool
1444+
vlocJoin(MachineBasicBlock &MBB, LiveIdxT &VLOCOutLocs,
1445+
SmallPtrSet<const MachineBasicBlock *, 8> &BlocksToExplore,
1446+
DbgValue &LiveIn);
14421447

14431448
/// For the given block and live-outs feeding into it, try to find
14441449
/// machine locations for each debug operand where all the values feeding
14451450
/// into that operand join together.
14461451
/// \returns true if a joined location was found for every value that needed
14471452
/// to be joined.
1448-
bool
1453+
LLVM_ABI_FOR_TEST bool
14491454
pickVPHILoc(SmallVectorImpl<DbgOpID> &OutValues, const MachineBasicBlock &MBB,
14501455
const LiveIdxT &LiveOuts, FuncValueTable &MOutLocs,
14511456
const SmallVectorImpl<const MachineBasicBlock *> &BlockOrders);
@@ -1461,7 +1466,7 @@ class InstrRefBasedLDV : public LDVImpl {
14611466

14621467
/// Boilerplate computation of some initial sets, artifical blocks and
14631468
/// RPOT block ordering.
1464-
void initialSetup(MachineFunction &MF);
1469+
LLVM_ABI_FOR_TEST void initialSetup(MachineFunction &MF);
14651470

14661471
/// Produce a map of the last lexical scope that uses a block, using the
14671472
/// scopes DFSOut number. Mapping is block-number to DFSOut.
@@ -1490,7 +1495,7 @@ class InstrRefBasedLDV : public LDVImpl {
14901495

14911496
public:
14921497
/// Default construct and initialize the pass.
1493-
InstrRefBasedLDV();
1498+
LLVM_ABI_FOR_TEST InstrRefBasedLDV();
14941499

14951500
LLVM_DUMP_METHOD
14961501
void dump_mloc_transfer(const MLocTransferMap &mloc_transfer) const;

llvm/lib/CodeGen/MLRegAllocEvictAdvisor.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/Analysis/MLModelRunner.h"
1818
#include "llvm/CodeGen/MachineBasicBlock.h"
1919
#include "llvm/CodeGen/SlotIndexes.h"
20+
#include "llvm/Support/Compiler.h"
2021
#include <map>
2122

2223
namespace llvm {
@@ -32,7 +33,7 @@ struct LRStartEndInfo {
3233
size_t Pos = 0;
3334
};
3435

35-
void extractInstructionFeatures(
36+
LLVM_ABI_FOR_TEST void extractInstructionFeatures(
3637
llvm::SmallVectorImpl<LRStartEndInfo> &LRPosInfo,
3738
MLModelRunner *RegallocRunner, function_ref<int(SlotIndex)> GetOpcode,
3839
function_ref<float(SlotIndex)> GetMBBFreq,
@@ -41,13 +42,12 @@ void extractInstructionFeatures(
4142
const int MBBFreqIndex, const int MBBMappingIndex,
4243
const SlotIndex LastIndex);
4344

44-
void extractMBBFrequency(const SlotIndex CurrentIndex,
45-
const size_t CurrentInstructionIndex,
46-
std::map<MachineBasicBlock *, size_t> &VisitedMBBs,
47-
function_ref<float(SlotIndex)> GetMBBFreq,
48-
MachineBasicBlock *CurrentMBBReference,
49-
MLModelRunner *RegallocRunner, const int MBBFreqIndex,
50-
const int MBBMappingIndex);
45+
LLVM_ABI_FOR_TEST void extractMBBFrequency(
46+
const SlotIndex CurrentIndex, const size_t CurrentInstructionIndex,
47+
std::map<MachineBasicBlock *, size_t> &VisitedMBBs,
48+
function_ref<float(SlotIndex)> GetMBBFreq,
49+
MachineBasicBlock *CurrentMBBReference, MLModelRunner *RegallocRunner,
50+
const int MBBFreqIndex, const int MBBMappingIndex);
5151

5252
// This is the maximum number of interfererring ranges. That's the number of
5353
// distinct AllocationOrder values, which comes from MCRegisterClass::RegsSize.

llvm/lib/CodeGen/RegAllocScore.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define LLVM_CODEGEN_REGALLOCSCORE_H_
1717

1818
#include "llvm/ADT/STLFunctionalExtras.h"
19+
#include "llvm/Support/Compiler.h"
1920

2021
namespace llvm {
2122

@@ -52,9 +53,9 @@ class RegAllocScore final {
5253
void onCheapRemat(double Freq) { CheapRematCounts += Freq; }
5354

5455
RegAllocScore &operator+=(const RegAllocScore &Other);
55-
bool operator==(const RegAllocScore &Other) const;
56+
LLVM_ABI_FOR_TEST bool operator==(const RegAllocScore &Other) const;
5657
bool operator!=(const RegAllocScore &Other) const;
57-
double getScore() const;
58+
LLVM_ABI_FOR_TEST double getScore() const;
5859
};
5960

6061
/// Calculate a score. When comparing 2 scores for the same function but
@@ -64,7 +65,7 @@ RegAllocScore calculateRegAllocScore(const MachineFunction &MF,
6465
const MachineBlockFrequencyInfo &MBFI);
6566

6667
/// Implementation of the above, which is also more easily unittestable.
67-
RegAllocScore calculateRegAllocScore(
68+
LLVM_ABI_FOR_TEST RegAllocScore calculateRegAllocScore(
6869
const MachineFunction &MF,
6970
llvm::function_ref<double(const MachineBasicBlock &)> GetBBFreq,
7071
llvm::function_ref<bool(const MachineInstr &)> IsTriviallyRematerializable);

0 commit comments

Comments
 (0)