Skip to content

Commit a142076

Browse files
committed
[NFC] Eliminate top-level "using namespace" from some headers.
- Eliminate top-level "using namespace" from some headers.
1 parent ac47edd commit a142076

File tree

18 files changed

+64
-74
lines changed

18 files changed

+64
-74
lines changed

llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
#include "llvm/Support/MemoryBuffer.h"
3030
#include "llvm/Target/TargetMachine.h"
3131

32-
using namespace llvm;
33-
3432
namespace llvm {
3533

3634
// This struct represents the cluster information for a machine basic block,

llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ void MLEvictAdvisor::extractFeatures(
943943
#undef SET
944944
}
945945

946-
void extractInstructionFeatures(
946+
void llvm::extractInstructionFeatures(
947947
SmallVectorImpl<LRStartEndInfo> &LRPosInfo, MLModelRunner *RegallocRunner,
948948
function_ref<int(SlotIndex)> GetOpcode,
949949
function_ref<float(SlotIndex)> GetMBBFreq,
@@ -1060,13 +1060,12 @@ void extractInstructionFeatures(
10601060
}
10611061
}
10621062

1063-
void extractMBBFrequency(const SlotIndex CurrentIndex,
1064-
const size_t CurrentInstructionIndex,
1065-
std::map<MachineBasicBlock *, size_t> &VisitedMBBs,
1066-
function_ref<float(SlotIndex)> GetMBBFreq,
1067-
MachineBasicBlock *CurrentMBBReference,
1068-
MLModelRunner *RegallocRunner, const int MBBFreqIndex,
1069-
const int MBBMappingIndex) {
1063+
void llvm::extractMBBFrequency(
1064+
const SlotIndex CurrentIndex, const size_t CurrentInstructionIndex,
1065+
std::map<MachineBasicBlock *, size_t> &VisitedMBBs,
1066+
function_ref<float(SlotIndex)> GetMBBFreq,
1067+
MachineBasicBlock *CurrentMBBReference, MLModelRunner *RegallocRunner,
1068+
const int MBBFreqIndex, const int MBBMappingIndex) {
10701069
size_t CurrentMBBIndex = VisitedMBBs[CurrentMBBReference];
10711070
float CurrentMBBFreq = GetMBBFreq(CurrentIndex);
10721071
if (CurrentMBBIndex < ModelMaxSupportedMBBCount) {

llvm/lib/CodeGen/MLRegAllocEvictAdvisor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "llvm/CodeGen/SlotIndexes.h"
2020
#include <map>
2121

22-
using namespace llvm;
22+
namespace llvm {
2323

2424
// LRStartEndInfo contains the start and end of a specific live range as
2525
// slot indices as well as storing the index of the physical register it
@@ -91,4 +91,6 @@ static const int64_t ModelMaxSupportedMBBCount = 100;
9191
static const std::vector<int64_t> MBBFrequencyShape{1,
9292
ModelMaxSupportedMBBCount};
9393

94+
} // namespace llvm
95+
9496
#endif // LLVM_CODEGEN_MLREGALLOCEVICTIONADVISOR_H

llvm/lib/CodeGen/SelectionDAG/MatchContext.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
#include "llvm/CodeGen/SelectionDAG.h"
1717
#include "llvm/CodeGen/TargetLowering.h"
1818

19-
using namespace llvm;
19+
namespace llvm {
2020

21-
namespace {
2221
class EmptyMatchContext {
2322
SelectionDAG &DAG;
2423
const TargetLowering &TLI;
@@ -171,5 +170,7 @@ class VPMatchContext {
171170
return TLI.isOperationLegalOrCustom(VPOp, VT, LegalOnly);
172171
}
173172
};
174-
} // end anonymous namespace
175-
#endif
173+
174+
} // namespace llvm
175+
176+
#endif // LLVM_LIB_CODEGEN_SELECTIONDAG_MATCHCONTEXT_H

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515

1616
#include "RuntimeDyldImpl.h"
1717

18-
#define DEBUG_TYPE "dyld"
19-
20-
using namespace llvm;
21-
2218
namespace llvm {
2319

2420
// Common base class for COFF dynamic linker support.
@@ -56,6 +52,4 @@ class RuntimeDyldCOFF : public RuntimeDyldImpl {
5652

5753
} // end namespace llvm
5854

59-
#undef DEBUG_TYPE
60-
61-
#endif
55+
#endif // LLVM_RUNTIME_DYLD_COFF_H

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include "RuntimeDyldImpl.h"
1717
#include "llvm/ADT/DenseMap.h"
1818

19-
using namespace llvm;
20-
2119
namespace llvm {
2220
namespace object {
2321
class ELFObjectFileBase;
@@ -233,4 +231,4 @@ class RuntimeDyldELF : public RuntimeDyldImpl {
233231

234232
} // end namespace llvm
235233

236-
#endif
234+
#endif // LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDELF_H

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
#include "llvm/Object/MachO.h"
1818
#include "llvm/Support/Format.h"
1919

20-
#define DEBUG_TYPE "dyld"
21-
22-
using namespace llvm;
23-
using namespace llvm::object;
24-
2520
namespace llvm {
2621
class RuntimeDyldMachO : public RuntimeDyldImpl {
2722
protected:
@@ -162,6 +157,4 @@ class RuntimeDyldMachOCRTPBase : public RuntimeDyldMachO {
162157

163158
} // end namespace llvm
164159

165-
#undef DEBUG_TYPE
166-
167-
#endif
160+
#endif // LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDMACHO_H

llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFAArch64.h

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//===-- RuntimeDyldCOFFAArch64.h --- COFF/AArch64 specific code ---*- C++
2-
//-*-===//
1+
//===-- RuntimeDyldCOFFAArch64.h --- COFF/AArch64 specific code ---*- C++*-===//
32
//
43
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
54
// See https://llvm.org/LICENSE.txt for license information.
@@ -22,8 +21,6 @@
2221

2322
#define DEBUG_TYPE "dyld"
2423

25-
using namespace llvm::support::endian;
26-
2724
namespace llvm {
2825

2926
// This relocation type is used for handling long branch instruction
@@ -32,16 +29,28 @@ enum InternalRelocationType : unsigned {
3229
INTERNAL_REL_ARM64_LONG_BRANCH26 = 0x111,
3330
};
3431

35-
static void add16(uint8_t *p, int16_t v) { write16le(p, read16le(p) + v); }
36-
static void or32le(void *P, int32_t V) { write32le(P, read32le(P) | V); }
32+
static void add16(uint8_t *p, int16_t v) {
33+
using namespace llvm::support::endian;
34+
write16le(p, read16le(p) + v);
35+
}
36+
37+
static void or32le(void *P, int32_t V) {
38+
using namespace llvm::support::endian;
39+
40+
write32le(P, read32le(P) | V);
41+
}
3742

3843
static void write32AArch64Imm(uint8_t *T, uint64_t imm, uint32_t rangeLimit) {
44+
using namespace llvm::support::endian;
45+
3946
uint32_t orig = read32le(T);
4047
orig &= ~(0xFFF << 10);
4148
write32le(T, orig | ((imm & (0xFFF >> rangeLimit)) << 10));
4249
}
4350

4451
static void write32AArch64Ldr(uint8_t *T, uint64_t imm) {
52+
using namespace llvm::support::endian;
53+
4554
uint32_t orig = read32le(T);
4655
uint32_t size = orig >> 30;
4756
// 0x04000000 indicates SIMD/FP registers
@@ -54,6 +63,8 @@ static void write32AArch64Ldr(uint8_t *T, uint64_t imm) {
5463
}
5564

5665
static void write32AArch64Addr(void *T, uint64_t s, uint64_t p, int shift) {
66+
using namespace llvm::support::endian;
67+
5768
uint64_t Imm = (s >> shift) - (p >> shift);
5869
uint32_t ImmLo = (Imm & 0x3) << 29;
5970
uint32_t ImmHi = (Imm & 0x1FFFFC) << 3;
@@ -144,6 +155,7 @@ class RuntimeDyldCOFFAArch64 : public RuntimeDyldCOFF {
144155
const object::ObjectFile &Obj,
145156
ObjSectionToIDMap &ObjSectionToID,
146157
StubMap &Stubs) override {
158+
using namespace llvm::support::endian;
147159

148160
auto Symbol = RelI->getSymbol();
149161
if (Symbol == Obj.symbol_end())
@@ -255,6 +267,8 @@ class RuntimeDyldCOFFAArch64 : public RuntimeDyldCOFF {
255267
}
256268

257269
void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override {
270+
using namespace llvm::support::endian;
271+
258272
const auto Section = Sections[RE.SectionID];
259273
uint8_t *Target = Section.getAddressWithOffset(RE.Offset);
260274
uint64_t FinalAddress = Section.getLoadAddressWithOffset(RE.Offset);
@@ -374,4 +388,6 @@ class RuntimeDyldCOFFAArch64 : public RuntimeDyldCOFF {
374388

375389
} // End namespace llvm
376390

377-
#endif
391+
#undef DEBUG_TYPE
392+
393+
#endif // LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFFAARCH64_H

llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
#include "llvm/CodeGen/GlobalISel/Combiner.h"
1919
#include "llvm/CodeGen/GlobalISel/CombinerHelper.h"
2020

21-
using namespace llvm;
22-
21+
namespace llvm {
2322
class AMDGPUCombinerHelper : public CombinerHelper {
2423
public:
2524
using CombinerHelper::CombinerHelper;
@@ -33,4 +32,6 @@ class AMDGPUCombinerHelper : public CombinerHelper {
3332
Register Src1, Register Src2);
3433
};
3534

35+
} // namespace llvm
36+
3637
#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUCOMBINERHELPER_H

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include "llvm/CodeGen/SelectionDAGISel.h"
2121
#include "llvm/Target/TargetMachine.h"
2222

23-
using namespace llvm;
24-
2523
namespace {
2624

2725
static inline bool getConstantValue(SDValue N, uint32_t &Out) {
@@ -62,6 +60,8 @@ static inline SDNode *packConstantV2I16(const SDNode *N, SelectionDAG &DAG) {
6260

6361
} // namespace
6462

63+
namespace llvm {
64+
6565
/// AMDGPU specific code to select AMDGPU machine instructions for
6666
/// SelectionDAG operations.
6767
class AMDGPUDAGToDAGISel : public SelectionDAGISel {
@@ -301,4 +301,6 @@ class AMDGPUDAGToDAGISelLegacy : public SelectionDAGISelLegacy {
301301
StringRef getPassName() const override;
302302
};
303303

304+
} // namespace llvm
305+
304306
#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUISELDAGTODAG_H

llvm/lib/Target/AMDGPU/R600MachineScheduler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include "llvm/CodeGen/MachineScheduler.h"
1818
#include <vector>
1919

20-
using namespace llvm;
21-
2220
namespace llvm {
2321

2422
class R600InstrInfo;

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendELF.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_LIB_TARGET_ARM_ELFARMASMBACKEND_H
10-
#define LLVM_LIB_TARGET_ARM_ELFARMASMBACKEND_H
9+
#ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ELFARMASMBACKEND_H
10+
#define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ELFARMASMBACKEND_H
1111

1212
#include "ARMAsmBackend.h"
1313
#include "MCTargetDesc/ARMMCTargetDesc.h"
1414
#include "llvm/MC/MCObjectWriter.h"
1515

16-
using namespace llvm;
17-
18-
namespace {
16+
namespace llvm {
1917
class ARMAsmBackendELF : public ARMAsmBackend {
2018
public:
2119
uint8_t OSABI;
@@ -30,6 +28,6 @@ class ARMAsmBackendELF : public ARMAsmBackend {
3028

3129
std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
3230
};
33-
}
31+
} // namespace llvm
3432

35-
#endif
33+
#endif // LLVM_LIB_TARGET_ARM_MCTARGETDESC_ELFARMASMBACKEND_H

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendWinCOFF.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_LIB_TARGET_ARM_ARMASMBACKENDWINCOFF_H
10-
#define LLVM_LIB_TARGET_ARM_ARMASMBACKENDWINCOFF_H
9+
#ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMASMBACKENDWINCOFF_H
10+
#define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMASMBACKENDWINCOFF_H
1111

1212
#include "ARMAsmBackend.h"
1313
#include "llvm/MC/MCObjectWriter.h"
14-
using namespace llvm;
1514

16-
namespace {
15+
namespace llvm {
1716
class ARMAsmBackendWinCOFF : public ARMAsmBackend {
1817
public:
1918
ARMAsmBackendWinCOFF(const Target &T, bool isThumb)
@@ -23,6 +22,6 @@ class ARMAsmBackendWinCOFF : public ARMAsmBackend {
2322
return createARMWinCOFFObjectWriter();
2423
}
2524
};
26-
}
25+
} // namespace llvm
2726

28-
#endif
27+
#endif // LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMASMBACKENDWINCOFF_H

llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "RISCVTargetStreamer.h"
1313
#include "llvm/MC/MCELFStreamer.h"
1414

15-
using namespace llvm;
15+
namespace llvm {
1616

1717
class RISCVELFStreamer : public MCELFStreamer {
1818
void reset() override;
@@ -75,5 +75,6 @@ MCELFStreamer *createRISCVELFStreamer(MCContext &C,
7575
std::unique_ptr<MCAsmBackend> MAB,
7676
std::unique_ptr<MCObjectWriter> MOW,
7777
std::unique_ptr<MCCodeEmitter> MCE);
78-
}
79-
#endif
78+
} // namespace llvm
79+
80+
#endif // LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H

llvm/lib/Target/SystemZ/SystemZMachineScheduler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "llvm/CodeGen/ScheduleDAG.h"
2323
#include <set>
2424

25-
using namespace llvm;
26-
2725
namespace llvm {
2826

2927
/// A MachineSchedStrategy implementation for SystemZ post RA scheduling.

llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombineInternal.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include "llvm/Analysis/ValueTracking.h"
2121
#include "llvm/Support/KnownBits.h"
2222

23-
using namespace llvm;
24-
2523
//===----------------------------------------------------------------------===//
2624
// TruncInstCombine - looks for expression graphs dominated by trunc
2725
// instructions and for each eligible graph, it will create a reduced bit-width
@@ -137,4 +135,4 @@ class TruncInstCombine {
137135
};
138136
} // end namespace llvm.
139137

140-
#endif
138+
#endif // LLVM_LIB_TRANSFORMS_AGGRESSIVEINSTCOMBINE_COMBINEINTERNAL_H

llvm/lib/Transforms/InstCombine/InstCombineInternal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#define DEBUG_TYPE "instcombine"
3434
#include "llvm/Transforms/Utils/InstructionWorklist.h"
3535

36-
using namespace llvm::PatternMatch;
37-
3836
// As a default, let's assume that we want to be aggressive,
3937
// and attempt to traverse with no limits in attempt to sink negation.
4038
static constexpr unsigned NegatorDefaultMaxDepth = ~0U;

llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,8 @@
4646
#include <type_traits>
4747
#include <utility>
4848

49-
namespace llvm {
50-
class DataLayout;
51-
class LLVMContext;
52-
} // namespace llvm
53-
5449
using namespace llvm;
50+
using namespace llvm::PatternMatch;
5551

5652
#define DEBUG_TYPE "instcombine"
5753

0 commit comments

Comments
 (0)