Skip to content
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
4 changes: 1 addition & 3 deletions llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"

namespace llvm {
using namespace llvm;

AIXException::AIXException(AsmPrinter *A) : EHStreamer(A) {}

Expand Down Expand Up @@ -90,5 +90,3 @@ void AIXException::endFunction(const MachineFunction *MF) {

emitExceptionInfoTable(LSDALabel, PerSym);
}

} // End of namespace llvm
4 changes: 1 addition & 3 deletions llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,14 @@ template <> struct llvm::DenseMapInfo<VariableID> {

using VarLocInsertPt = PointerUnion<const Instruction *, const DbgRecord *>;

namespace std {
template <> struct hash<VarLocInsertPt> {
template <> struct std::hash<VarLocInsertPt> {
using argument_type = VarLocInsertPt;
using result_type = std::size_t;

result_type operator()(const argument_type &Arg) const {
return std::hash<void *>()(Arg.getOpaqueValue());
}
};
} // namespace std

/// Helper class to build FunctionVarLocs, since that class isn't easy to
/// modify. TODO: There's not a great deal of value in the split, it could be
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/CodeGen/BasicBlockPathCloning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ bool ApplyCloning(MachineFunction &MF,
}
return AnyPathsCloned;
}
} // end anonymous namespace

namespace llvm {
class BasicBlockPathCloning : public MachineFunctionPass {
public:
static char ID;
Expand All @@ -229,7 +227,7 @@ class BasicBlockPathCloning : public MachineFunctionPass {
bool runOnMachineFunction(MachineFunction &MF) override;
};

} // namespace llvm
} // namespace

char BasicBlockPathCloning::ID = 0;
INITIALIZE_PASS_BEGIN(
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/BreakFalseDeps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

using namespace llvm;

namespace llvm {
namespace {

class BreakFalseDeps : public MachineFunctionPass {
private:
Expand Down Expand Up @@ -95,7 +95,7 @@ class BreakFalseDeps : public MachineFunctionPass {
void processUndefReads(MachineBasicBlock *);
};

} // namespace llvm
} // namespace

#define DEBUG_TYPE "break-false-deps"

Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ hash_code hash_value(const ComplexValue &Arg) {
} // end namespace
typedef SmallVector<struct ComplexValue, 2> ComplexValues;

namespace llvm {
template <> struct DenseMapInfo<ComplexValue> {
template <> struct llvm::DenseMapInfo<ComplexValue> {
static inline ComplexValue getEmptyKey() {
return {DenseMapInfo<Value *>::getEmptyKey(),
DenseMapInfo<Value *>::getEmptyKey()};
Expand All @@ -144,7 +143,6 @@ template <> struct DenseMapInfo<ComplexValue> {
return LHS.Real == RHS.Real && LHS.Imag == RHS.Imag;
}
};
} // end namespace llvm

namespace {
template <typename T, typename IterT>
Expand Down
11 changes: 3 additions & 8 deletions llvm/lib/CodeGen/EdgeBundles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,10 @@ void EdgeBundles::init() {
}
}

namespace llvm {

/// Specialize WriteGraph, the standard implementation won't work.
template<>
raw_ostream &WriteGraph<>(raw_ostream &O, const EdgeBundles &G,
bool ShortNames,
const Twine &Title) {
template <>
raw_ostream &llvm::WriteGraph<>(raw_ostream &O, const EdgeBundles &G,
bool ShortNames, const Twine &Title) {
const MachineFunction *MF = G.getMachineFunction();

O << "digraph {\n";
Expand All @@ -107,8 +104,6 @@ raw_ostream &WriteGraph<>(raw_ostream &O, const EdgeBundles &G,
return O;
}

} // end namespace llvm

/// view - Visualize the annotated bipartite CFG with Graphviz.
void EdgeBundles::view() const {
ViewGraph(*this, "EdgeBundles");
Expand Down
10 changes: 3 additions & 7 deletions llvm/lib/CodeGen/GlobalMergeFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,16 +587,12 @@ class GlobalMergeFuncPassWrapper : public ModulePass {
} // namespace

char GlobalMergeFuncPassWrapper::ID = 0;
INITIALIZE_PASS_BEGIN(GlobalMergeFuncPassWrapper, "global-merge-func",
"Global merge function pass", false, false)
INITIALIZE_PASS_END(GlobalMergeFuncPassWrapper, "global-merge-func",
"Global merge function pass", false, false)
INITIALIZE_PASS(GlobalMergeFuncPassWrapper, "global-merge-func",
"Global merge function pass", false, false)

namespace llvm {
ModulePass *createGlobalMergeFuncPass() {
ModulePass *llvm::createGlobalMergeFuncPass() {
return new GlobalMergeFuncPassWrapper();
}
} // namespace llvm

GlobalMergeFuncPassWrapper::GlobalMergeFuncPassWrapper() : ModulePass(ID) {
initializeGlobalMergeFuncPassWrapperPass(
Expand Down
6 changes: 1 addition & 5 deletions llvm/lib/CodeGen/LiveIntervals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,11 @@ static cl::opt<bool> EnablePrecomputePhysRegs(
static bool EnablePrecomputePhysRegs = false;
#endif // NDEBUG

namespace llvm {

cl::opt<bool> UseSegmentSetForPhysRegs(
cl::opt<bool> llvm::UseSegmentSetForPhysRegs(
"use-segment-set-for-physregs", cl::Hidden, cl::init(true),
cl::desc(
"Use segment set for the computation of the live ranges of physregs."));

} // end namespace llvm

void LiveIntervalsWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG();
AU.addPreserved<LiveVariablesWrapperPass>();
Expand Down
13 changes: 5 additions & 8 deletions llvm/lib/CodeGen/MIR2Vec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,17 @@ using namespace mir2vec;
STATISTIC(MIRVocabMissCounter,
"Number of lookups to MIR entities not present in the vocabulary");

namespace llvm {
namespace mir2vec {
cl::OptionCategory MIR2VecCategory("MIR2Vec Options");
cl::OptionCategory llvm::mir2vec::MIR2VecCategory("MIR2Vec Options");

// FIXME: Use a default vocab when not specified
static cl::opt<std::string>
VocabFile("mir2vec-vocab-path", cl::Optional,
cl::desc("Path to the vocabulary file for MIR2Vec"), cl::init(""),
cl::cat(MIR2VecCategory));
cl::opt<float> OpcWeight("mir2vec-opc-weight", cl::Optional, cl::init(1.0),
cl::desc("Weight for machine opcode embeddings"),
cl::cat(MIR2VecCategory));
} // namespace mir2vec
} // namespace llvm
cl::opt<float>
llvm::mir2vec::OpcWeight("mir2vec-opc-weight", cl::Optional, cl::init(1.0),
cl::desc("Weight for machine opcode embeddings"),
cl::cat(MIR2VecCategory));

//===----------------------------------------------------------------------===//
// Vocabulary Implementation
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MIRFSDiscriminator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cl::opt<bool> ImprovedFSDiscriminator(
"improved-fs-discriminator", cl::Hidden, cl::init(false),
cl::desc("New FS discriminators encoding (incompatible with the original "
"encoding)"));
}
} // namespace llvm

char MIRAddFSDiscriminators::ID = 0;

Expand Down
6 changes: 1 addition & 5 deletions llvm/lib/CodeGen/MIRPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ struct MFPrintState {

} // end anonymous namespace

namespace llvm::yaml {

/// This struct serializes the LLVM IR module.
template <> struct BlockScalarTraits<Module> {
template <> struct yaml::BlockScalarTraits<Module> {
static void output(const Module &Mod, void *Ctxt, raw_ostream &OS) {
Mod.print(OS, nullptr);
}
Expand All @@ -121,8 +119,6 @@ template <> struct BlockScalarTraits<Module> {
}
};

} // end namespace llvm::yaml

static void printRegMIR(Register Reg, yaml::StringValue &Dest,
const TargetRegisterInfo *TRI) {
raw_string_ostream OS(Dest.Value);
Expand Down
9 changes: 6 additions & 3 deletions llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ static const bool EnableDevelopmentFeatures = false;
/// this happens only in development mode. It's a no-op otherwise.
namespace llvm {
extern cl::opt<unsigned> EvictInterferenceCutoff;
} // namespace llvm

namespace {
class RegAllocScoring : public MachineFunctionPass {
public:
static char ID;
Expand All @@ -124,11 +126,12 @@ class RegAllocScoring : public MachineFunctionPass {
/// Performs this pass
bool runOnMachineFunction(MachineFunction &) override;
};
} // namespace

char RegAllocScoring::ID = 0;
FunctionPass *createRegAllocScoringPass() { return new RegAllocScoring(); }

} // namespace llvm
FunctionPass *llvm::createRegAllocScoringPass() {
return new RegAllocScoring();
}

INITIALIZE_PASS(RegAllocScoring, "regallocscoringpass",
"Register Allocation Scoring Pass", false, false)
Expand Down
18 changes: 7 additions & 11 deletions llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ using namespace llvm;

#define DEBUG_TYPE "machine-block-freq"

namespace llvm {
static cl::opt<GVDAGType> ViewMachineBlockFreqPropagationDAG(
"view-machine-block-freq-propagation-dags", cl::Hidden,
cl::desc("Pop up a window to show a dag displaying how machine block "
Expand All @@ -44,6 +43,7 @@ static cl::opt<GVDAGType> ViewMachineBlockFreqPropagationDAG(
clEnumValN(GVDT_Count, "count", "display a graph using the real "
"profile count if available.")));

namespace llvm {
// Similar option above, but used to control BFI display only after MBP pass
cl::opt<GVDAGType> ViewBlockLayoutWithBFI(
"view-block-layout-with-bfi", cl::Hidden,
Expand All @@ -69,25 +69,23 @@ extern cl::opt<std::string> ViewBlockFreqFuncName;
// Defined in Analysis/BlockFrequencyInfo.cpp: -view-hot-freq-perc=
extern cl::opt<unsigned> ViewHotFreqPercent;

static cl::opt<bool> PrintMachineBlockFreq(
"print-machine-bfi", cl::init(false), cl::Hidden,
cl::desc("Print the machine block frequency info."));

// Command line option to specify the name of the function for block frequency
// dump. Defined in Analysis/BlockFrequencyInfo.cpp.
extern cl::opt<std::string> PrintBFIFuncName;
} // namespace llvm

static cl::opt<bool>
PrintMachineBlockFreq("print-machine-bfi", cl::init(false), cl::Hidden,
cl::desc("Print the machine block frequency info."));

static GVDAGType getGVDT() {
if (ViewBlockLayoutWithBFI != GVDT_None)
return ViewBlockLayoutWithBFI;

return ViewMachineBlockFreqPropagationDAG;
}

namespace llvm {

template <> struct GraphTraits<MachineBlockFrequencyInfo *> {
template <> struct llvm::GraphTraits<MachineBlockFrequencyInfo *> {
using NodeRef = const MachineBasicBlock *;
using ChildIteratorType = MachineBasicBlock::const_succ_iterator;
using nodes_iterator = pointer_iterator<MachineFunction::const_iterator>;
Expand Down Expand Up @@ -116,7 +114,7 @@ using MBFIDOTGraphTraitsBase =
MachineBranchProbabilityInfo>;

template <>
struct DOTGraphTraits<MachineBlockFrequencyInfo *>
struct llvm::DOTGraphTraits<MachineBlockFrequencyInfo *>
: public MBFIDOTGraphTraitsBase {
const MachineFunction *CurFunc = nullptr;
DenseMap<const MachineBasicBlock *, int> LayoutOrderMap;
Expand Down Expand Up @@ -159,8 +157,6 @@ struct DOTGraphTraits<MachineBlockFrequencyInfo *>
}
};

} // end namespace llvm

AnalysisKey MachineBlockFrequencyAnalysis::Key;

MachineBlockFrequencyAnalysis::Result
Expand Down
9 changes: 2 additions & 7 deletions llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@

using namespace llvm;

INITIALIZE_PASS_BEGIN(MachineBranchProbabilityInfoWrapperPass,
"machine-branch-prob",
"Machine Branch Probability Analysis", false, true)
INITIALIZE_PASS_END(MachineBranchProbabilityInfoWrapperPass,
"machine-branch-prob",
"Machine Branch Probability Analysis", false, true)

INITIALIZE_PASS(MachineBranchProbabilityInfoWrapperPass, "machine-branch-prob",
"Machine Branch Probability Analysis", false, true)
namespace llvm {
cl::opt<unsigned>
StaticLikelyProb("static-likely-prob",
Expand Down
62 changes: 30 additions & 32 deletions llvm/lib/CodeGen/MachineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,43 +719,41 @@ MachineFunction::CallSiteInfo::CallSiteInfo(const CallBase &CB) {
}
}

namespace llvm {
template <>
struct llvm::DOTGraphTraits<const MachineFunction *>
: public DefaultDOTGraphTraits {
DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}

template<>
struct DOTGraphTraits<const MachineFunction*> : public DefaultDOTGraphTraits {
DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
static std::string getGraphName(const MachineFunction *F) {
return ("CFG for '" + F->getName() + "' function").str();
}

static std::string getGraphName(const MachineFunction *F) {
return ("CFG for '" + F->getName() + "' function").str();
std::string getNodeLabel(const MachineBasicBlock *Node,
const MachineFunction *Graph) {
std::string OutStr;
{
raw_string_ostream OSS(OutStr);

if (isSimple()) {
OSS << printMBBReference(*Node);
if (const BasicBlock *BB = Node->getBasicBlock())
OSS << ": " << BB->getName();
} else
Node->print(OSS);
}

std::string getNodeLabel(const MachineBasicBlock *Node,
const MachineFunction *Graph) {
std::string OutStr;
{
raw_string_ostream OSS(OutStr);

if (isSimple()) {
OSS << printMBBReference(*Node);
if (const BasicBlock *BB = Node->getBasicBlock())
OSS << ": " << BB->getName();
} else
Node->print(OSS);
}

if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());

// Process string output to make it nicer...
for (unsigned i = 0; i != OutStr.length(); ++i)
if (OutStr[i] == '\n') { // Left justify
OutStr[i] = '\\';
OutStr.insert(OutStr.begin()+i+1, 'l');
}
return OutStr;
}
};
if (OutStr[0] == '\n')
OutStr.erase(OutStr.begin());

} // end namespace llvm
// Process string output to make it nicer...
for (unsigned i = 0; i != OutStr.length(); ++i)
if (OutStr[i] == '\n') { // Left justify
OutStr[i] = '\\';
OutStr.insert(OutStr.begin() + i + 1, 'l');
}
return OutStr;
}
};

void MachineFunction::viewCFG() const
{
Expand Down
Loading