Skip to content

Commit

Permalink
Move helpers into anonymous namespaces. NFC.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277916 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
d0k committed Aug 6, 2016
1 parent bc3aa5c commit 284030a
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 24 deletions.
2 changes: 0 additions & 2 deletions lib/CodeGen/AsmPrinter/AddressPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

using namespace llvm;

class MCExpr;

unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) {
HasBeenUsed = true;
auto IterBool =
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ bool DwarfDebug::isLexicalScopeDIENull(LexicalScope *Scope) {
return !getLabelAfterInsn(Ranges.front().second);
}

template <typename Func> void forBothCUs(DwarfCompileUnit &CU, Func F) {
template <typename Func> static void forBothCUs(DwarfCompileUnit &CU, Func F) {
F(CU);
if (auto *SkelCU = CU.getSkeleton())
F(*SkelCU);
Expand Down
7 changes: 4 additions & 3 deletions lib/CodeGen/LiveRegMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ void LiveRegMatrix::releaseMemory() {
}
}

template<typename Callable>
bool foreachUnit(const TargetRegisterInfo *TRI, LiveInterval &VRegInterval,
unsigned PhysReg, Callable Func) {
template <typename Callable>
static bool foreachUnit(const TargetRegisterInfo *TRI,
LiveInterval &VRegInterval, unsigned PhysReg,
Callable Func) {
if (VRegInterval.hasSubRanges()) {
for (MCRegUnitMaskIterator Units(PhysReg, TRI); Units.isValid(); ++Units) {
unsigned Unit = (*Units).first;
Expand Down
5 changes: 3 additions & 2 deletions lib/CodeGen/MachinePipeliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ STATISTIC(NumTrytoPipeline, "Number of loops that we attempt to pipeline");
STATISTIC(NumPipelined, "Number of loops software pipelined");

/// A command line option to turn software pipelining on or off.
cl::opt<bool> EnableSWP("enable-pipeliner", cl::Hidden, cl::init(true),
cl::ZeroOrMore, cl::desc("Enable Software Pipelining"));
static cl::opt<bool> EnableSWP("enable-pipeliner", cl::Hidden, cl::init(true),
cl::ZeroOrMore,
cl::desc("Enable Software Pipelining"));

/// A command line option to enable SWP at -Os.
static cl::opt<bool> EnableSWPOptSize("enable-pipeliner-opt-size",
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/RegisterUsageInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace llvm;

#define DEBUG_TYPE "ip-regalloc"

cl::opt<bool> DumpRegUsage(
static cl::opt<bool> DumpRegUsage(
"print-regusage", cl::init(false), cl::Hidden,
cl::desc("print register usage details collected for analysis."));

Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/ShrinkWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ bool ShrinkWrap::useOrDefCSROrFI(const MachineInstr &MI,

/// \brief Helper function to find the immediate (post) dominator.
template <typename ListOfBBs, typename DominanceAnalysis>
MachineBasicBlock *FindIDom(MachineBasicBlock &Block, ListOfBBs BBs,
DominanceAnalysis &Dom) {
static MachineBasicBlock *FindIDom(MachineBasicBlock &Block, ListOfBBs BBs,
DominanceAnalysis &Dom) {
MachineBasicBlock *IDom = &Block;
for (MachineBasicBlock *BB : BBs) {
IDom = Dom.findNearestCommonDominator(IDom, BB);
Expand Down
8 changes: 3 additions & 5 deletions lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ static bool isScope(const Metadata *MD) { return !MD || isa<DIScope>(MD); }
static bool isDINode(const Metadata *MD) { return !MD || isa<DINode>(MD); }

template <class Ty>
bool isValidMetadataArrayImpl(const MDTuple &N, bool AllowNull) {
static bool isValidMetadataArrayImpl(const MDTuple &N, bool AllowNull) {
for (Metadata *MD : N.operands()) {
if (MD) {
if (!isa<Ty>(MD))
Expand All @@ -775,13 +775,11 @@ bool isValidMetadataArrayImpl(const MDTuple &N, bool AllowNull) {
return true;
}

template <class Ty>
bool isValidMetadataArray(const MDTuple &N) {
template <class Ty> static bool isValidMetadataArray(const MDTuple &N) {
return isValidMetadataArrayImpl<Ty>(N, /* AllowNull */ false);
}

template <class Ty>
bool isValidMetadataNullArray(const MDTuple &N) {
template <class Ty> static bool isValidMetadataNullArray(const MDTuple &N) {
return isValidMetadataArrayImpl<Ty>(N, /* AllowNull */ true);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Target/AArch64/AArch64FrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ static bool produceCompactUnwindFrame(MachineFunction &MF) {
Attrs.hasAttrSomewhere(Attribute::SwiftError));
}


namespace {
struct RegPairInfo {
RegPairInfo() : Reg1(AArch64::NoRegister), Reg2(AArch64::NoRegister) {}
unsigned Reg1;
Expand All @@ -879,6 +879,7 @@ struct RegPairInfo {
bool IsGPR;
bool isPaired() const { return Reg2 != AArch64::NoRegister; }
};
} // end anonymous namespace

static void computeCalleeSaveRegisterPairs(
MachineFunction &MF, const std::vector<CalleeSavedInfo> &CSI,
Expand Down
2 changes: 2 additions & 0 deletions lib/Target/AArch64/AArch64InstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ static bool areCFlagsAliveInSuccessors(MachineBasicBlock *MBB) {
return false;
}

namespace {
struct UsedNZCV {
bool N;
bool Z;
Expand All @@ -1042,6 +1043,7 @@ struct UsedNZCV {
return *this;
}
};
} // end anonymous namespace

/// Find a condition code used by the instruction.
/// Returns AArch64CC::Invalid if either the instruction does not use condition
Expand Down
2 changes: 2 additions & 0 deletions lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,7 @@ int HexagonDAGToDAGISel::getHeight(SDNode *N) {
return RootHeights[N];
}

namespace {
struct WeightedLeaf {
SDValue Value;
int Weight;
Expand Down Expand Up @@ -1673,6 +1674,7 @@ class LeafPrioQueue {
LeafPrioQueue(unsigned Opcode) :
HaveConst(false), Opcode(Opcode) { }
};
} // end anonymous namespace

WeightedLeaf LeafPrioQueue::findSHL(uint64_t MaxAmount) {
int ResultPos;
Expand Down
2 changes: 2 additions & 0 deletions lib/Target/Hexagon/HexagonMachineScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ using namespace llvm;

#define DEBUG_TYPE "misched"

namespace {
class HexagonCallMutation : public ScheduleDAGMutation {
public:
void apply(ScheduleDAGInstrs *DAG) override;
private:
bool shouldTFRICallBind(const HexagonInstrInfo &HII,
const SUnit &Inst1, const SUnit &Inst2) const;
};
} // end anonymous namespace

// Check if a call and subsequent A2_tfrpi instructions should maintain
// scheduling affinity. We are looking for the TFRI to be consumed in
Expand Down
10 changes: 4 additions & 6 deletions lib/Target/X86/X86OptimizeLEAs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ static cl::opt<bool>
STATISTIC(NumSubstLEAs, "Number of LEA instruction substitutions");
STATISTIC(NumRedundantLEAs, "Number of redundant LEA instructions removed");

class MemOpKey;

/// \brief Returns a hash table key based on memory operands of \p MI. The
/// number of the first memory operand of \p MI is specified through \p N.
static inline MemOpKey getMemOpKey(const MachineInstr &MI, unsigned N);

/// \brief Returns true if two machine operands are identical and they are not
/// physical registers.
static inline bool isIdenticalOp(const MachineOperand &MO1,
Expand All @@ -63,6 +57,7 @@ static bool isSimilarDispOp(const MachineOperand &MO1,
/// \brief Returns true if the instruction is LEA.
static inline bool isLEA(const MachineInstr &MI);

namespace {
/// A key based on instruction's memory operands.
class MemOpKey {
public:
Expand Down Expand Up @@ -95,6 +90,7 @@ class MemOpKey {
// Address' displacement operand.
const MachineOperand *Disp;
};
} // end anonymous namespace

/// Provide DenseMapInfo for MemOpKey.
namespace llvm {
Expand Down Expand Up @@ -168,6 +164,8 @@ template <> struct DenseMapInfo<MemOpKey> {
};
}

/// \brief Returns a hash table key based on memory operands of \p MI. The
/// number of the first memory operand of \p MI is specified through \p N.
static inline MemOpKey getMemOpKey(const MachineInstr &MI, unsigned N) {
assert((isLEA(MI) || MI.mayLoadOrStore()) &&
"The instruction must be a LEA, a load or a store");
Expand Down
2 changes: 2 additions & 0 deletions lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,7 @@ bool llvm::callsGCLeafFunction(ImmutableCallSite CS) {
return false;
}

namespace {
/// A potential constituent of a bitreverse or bswap expression. See
/// collectBitParts for a fuller explanation.
struct BitPart {
Expand All @@ -1718,6 +1719,7 @@ struct BitPart {

enum { Unset = -1 };
};
} // end anonymous namespace

/// Analyze the specified subexpression and see if it is capable of providing
/// pieces of a bswap or bitreverse. The subexpression provides a potential
Expand Down
2 changes: 2 additions & 0 deletions lib/Transforms/Utils/NameAnonFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

using namespace llvm;

namespace {
// Compute a "unique" hash for the module based on the name of the public
// functions.
class ModuleHasher {
Expand Down Expand Up @@ -57,6 +58,7 @@ class ModuleHasher {
return TheHash;
}
};
} // end anonymous namespace

// Rename all the anon functions in the module
bool llvm::nameUnamedFunctions(Module &M) {
Expand Down
3 changes: 2 additions & 1 deletion lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3942,7 +3942,7 @@ static Value *createRdxShuffleMask(unsigned VecLen, unsigned NumEltsToRdx,
return ConstantVector::get(ShuffleMask);
}


namespace {
/// Model horizontal reductions.
///
/// A horizontal reduction is a tree of reduction operations (currently add and
Expand Down Expand Up @@ -4228,6 +4228,7 @@ class HorizontalReduction {
return Builder.CreateExtractElement(TmpVec, Builder.getInt32(0));
}
};
} // end anonymous namespace

/// \brief Recognize construction of vectors like
/// %ra = insertelement <4 x float> undef, float %s0, i32 0
Expand Down

0 comments on commit 284030a

Please sign in to comment.