Skip to content

[llvm] export private symbols needed by unittests #145767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/AsmPrinter/DIEHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "llvm/ADT/DenseMap.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MD5.h"

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

/// Computes the type signature.
uint64_t computeTypeSignature(const DIE &Die);
LLVM_ABI uint64_t computeTypeSignature(const DIE &Die);

// Helper routines to process parts of a DIE.
private:
Expand Down
19 changes: 11 additions & 8 deletions llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/DwarfStringPoolEntry.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Compiler.h"

namespace llvm {

Expand All @@ -37,14 +38,16 @@ class DwarfStringPool {
public:
using EntryRef = DwarfStringPoolEntryRef;

DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix);
LLVM_ABI DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm,
StringRef Prefix);

void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection,
MCSymbol *StartSym);
LLVM_ABI void emitStringOffsetsTableHeader(AsmPrinter &Asm,
MCSection *OffsetSection,
MCSymbol *StartSym);

void emit(AsmPrinter &Asm, MCSection *StrSection,
MCSection *OffsetSection = nullptr,
bool UseRelativeOffsets = false);
LLVM_ABI void emit(AsmPrinter &Asm, MCSection *StrSection,
MCSection *OffsetSection = nullptr,
bool UseRelativeOffsets = false);

bool empty() const { return Pool.empty(); }

Expand All @@ -53,12 +56,12 @@ class DwarfStringPool {
unsigned getNumIndexedStrings() const { return NumIndexedStrings; }

/// Get a reference to an entry in the string pool.
EntryRef getEntry(AsmPrinter &Asm, StringRef Str);
LLVM_ABI EntryRef getEntry(AsmPrinter &Asm, StringRef Str);

/// Same as getEntry, except that you can use EntryRef::getIndex to obtain a
/// unique ID of this entry (e.g., for use in indexed forms like
/// DW_FORM_strx).
EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str);
LLVM_ABI EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str);
};

} // end namespace llvm
Expand Down
59 changes: 32 additions & 27 deletions llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/Support/Compiler.h"
#include <optional>

#include "LiveDebugValues.h"
Expand Down Expand Up @@ -204,8 +205,8 @@ class ValueIDNum {
.str();
}

static ValueIDNum EmptyValue;
static ValueIDNum TombstoneValue;
LLVM_ABI static ValueIDNum EmptyValue;
LLVM_ABI static ValueIDNum TombstoneValue;
};

} // End namespace LiveDebugValues
Expand Down Expand Up @@ -425,7 +426,7 @@ struct DbgOpID {
DbgOpID(uint32_t RawID) : RawID(RawID) {}
DbgOpID(bool IsConst, uint32_t Index) : ID({IsConst, Index}) {}

static DbgOpID UndefID;
LLVM_ABI static DbgOpID UndefID;

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

MLocTracker(MachineFunction &MF, const TargetInstrInfo &TII,
const TargetRegisterInfo &TRI, const TargetLowering &TLI);
LLVM_ABI MLocTracker(MachineFunction &MF, const TargetInstrInfo &TII,
const TargetRegisterInfo &TRI,
const TargetLowering &TLI);

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

/// Create a LocIdx for an untracked register ID. Initialize it to either an
/// mphi value representing a live-in, or a recent register mask clobber.
LocIdx trackRegister(unsigned ID);
LLVM_ABI LocIdx trackRegister(unsigned ID);

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

// Get LocIdx of a spill ID.
LocIdx getSpillMLoc(unsigned SpillID) {
Expand Down Expand Up @@ -1342,7 +1344,7 @@ class InstrRefBasedLDV : public LDVImpl {
/// in an MLocTracker. Convert the observations into a per-block transfer
/// function in \p MLocTransfer, suitable for using with the machine value
/// location dataflow problem.
void
LLVM_ABI void
produceMLocTransferFunction(MachineFunction &MF,
SmallVectorImpl<MLocTransferMap> &MLocTransfer,
unsigned MaxNumBlocks);
Expand All @@ -1352,20 +1354,21 @@ class InstrRefBasedLDV : public LDVImpl {
/// live-out arrays to the (initialized to zero) multidimensional arrays in
/// \p MInLocs and \p MOutLocs. The outer dimension is indexed by block
/// number, the inner by LocIdx.
void buildMLocValueMap(MachineFunction &MF, FuncValueTable &MInLocs,
FuncValueTable &MOutLocs,
SmallVectorImpl<MLocTransferMap> &MLocTransfer);
LLVM_ABI void
buildMLocValueMap(MachineFunction &MF, FuncValueTable &MInLocs,
FuncValueTable &MOutLocs,
SmallVectorImpl<MLocTransferMap> &MLocTransfer);

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

/// Install PHI values into the live-in array for each block, according to
/// the IDF of each register.
void placeMLocPHIs(MachineFunction &MF,
SmallPtrSetImpl<MachineBasicBlock *> &AllBlocks,
FuncValueTable &MInLocs,
SmallVectorImpl<MLocTransferMap> &MLocTransfer);
LLVM_ABI void placeMLocPHIs(MachineFunction &MF,
SmallPtrSetImpl<MachineBasicBlock *> &AllBlocks,
FuncValueTable &MInLocs,
SmallVectorImpl<MLocTransferMap> &MLocTransfer);

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

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

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

/// Boilerplate computation of some initial sets, artifical blocks and
/// RPOT block ordering.
void initialSetup(MachineFunction &MF);
LLVM_ABI void initialSetup(MachineFunction &MF);

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

public:
/// Default construct and initialize the pass.
InstrRefBasedLDV();
LLVM_ABI InstrRefBasedLDV();

LLVM_DUMP_METHOD
void dump_mloc_transfer(const MLocTransferMap &mloc_transfer) const;
Expand Down
16 changes: 8 additions & 8 deletions llvm/lib/CodeGen/MLRegAllocEvictAdvisor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "llvm/Analysis/MLModelRunner.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/SlotIndexes.h"
#include "llvm/Support/Compiler.h"
#include <map>

namespace llvm {
Expand All @@ -32,7 +33,7 @@ struct LRStartEndInfo {
size_t Pos = 0;
};

void extractInstructionFeatures(
LLVM_ABI void extractInstructionFeatures(
llvm::SmallVectorImpl<LRStartEndInfo> &LRPosInfo,
MLModelRunner *RegallocRunner, function_ref<int(SlotIndex)> GetOpcode,
function_ref<float(SlotIndex)> GetMBBFreq,
Expand All @@ -41,13 +42,12 @@ void extractInstructionFeatures(
const int MBBFreqIndex, const int MBBMappingIndex,
const SlotIndex LastIndex);

void extractMBBFrequency(const SlotIndex CurrentIndex,
const size_t CurrentInstructionIndex,
std::map<MachineBasicBlock *, size_t> &VisitedMBBs,
function_ref<float(SlotIndex)> GetMBBFreq,
MachineBasicBlock *CurrentMBBReference,
MLModelRunner *RegallocRunner, const int MBBFreqIndex,
const int MBBMappingIndex);
LLVM_ABI void extractMBBFrequency(
const SlotIndex CurrentIndex, const size_t CurrentInstructionIndex,
std::map<MachineBasicBlock *, size_t> &VisitedMBBs,
function_ref<float(SlotIndex)> GetMBBFreq,
MachineBasicBlock *CurrentMBBReference, MLModelRunner *RegallocRunner,
const int MBBFreqIndex, const int MBBMappingIndex);

// This is the maximum number of interfererring ranges. That's the number of
// distinct AllocationOrder values, which comes from MCRegisterClass::RegsSize.
Expand Down
7 changes: 4 additions & 3 deletions llvm/lib/CodeGen/RegAllocScore.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define LLVM_CODEGEN_REGALLOCSCORE_H_

#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/Support/Compiler.h"

namespace llvm {

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

RegAllocScore &operator+=(const RegAllocScore &Other);
bool operator==(const RegAllocScore &Other) const;
LLVM_ABI bool operator==(const RegAllocScore &Other) const;
bool operator!=(const RegAllocScore &Other) const;
double getScore() const;
LLVM_ABI double getScore() const;
};

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

/// Implementation of the above, which is also more easily unittestable.
RegAllocScore calculateRegAllocScore(
LLVM_ABI RegAllocScore calculateRegAllocScore(
const MachineFunction &MF,
llvm::function_ref<double(const MachineBasicBlock &)> GetBBFreq,
llvm::function_ref<bool(const MachineInstr &)> IsTriviallyRematerializable);
Expand Down
Loading