From bfaa3adccc32fd5da30b8d593009dd30765f0870 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 11 Feb 2017 11:06:55 +0000 Subject: [PATCH] Move symbols from the global namespace into (anonymous) namespaces. NFC. llvm-svn: 294837 --- lib/Bitcode/Reader/MetadataLoader.cpp | 2 +- lib/Bitcode/Writer/BitcodeWriter.cpp | 2 +- lib/ObjectYAML/DWARFEmitter.cpp | 19 ++++++++++--------- .../MCTargetDesc/HexagonMCTargetDesc.cpp | 5 +---- .../MCTargetDesc/HexagonMCTargetDesc.h | 3 ++- lib/Target/PowerPC/PPCExpandISEL.cpp | 2 ++ lib/Target/X86/X86InterleavedAccess.cpp | 3 ++- lib/Transforms/Scalar/NewGVN.cpp | 11 ++--------- lib/XRay/Trace.cpp | 8 ++++---- 9 files changed, 25 insertions(+), 30 deletions(-) diff --git a/lib/Bitcode/Reader/MetadataLoader.cpp b/lib/Bitcode/Reader/MetadataLoader.cpp index 3baf0599341..603b8141838 100644 --- a/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/lib/Bitcode/Reader/MetadataLoader.cpp @@ -567,7 +567,7 @@ public: void shrinkTo(unsigned N) { MetadataList.shrinkTo(N); } }; -Error error(const Twine &Message) { +static Error error(const Twine &Message) { return make_error( Message, make_error_code(BitcodeError::CorruptedBitcode)); } diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 1281fca5f69..8e930c01998 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -3739,7 +3739,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { /// Create the "IDENTIFICATION_BLOCK_ID" containing a single string with the /// current llvm version, and a record for the epoch number. -void writeIdentificationBlock(BitstreamWriter &Stream) { +static void writeIdentificationBlock(BitstreamWriter &Stream) { Stream.EnterSubblock(bitc::IDENTIFICATION_BLOCK_ID, 5); // Write the "user readable" string identifying the bitcode producer diff --git a/lib/ObjectYAML/DWARFEmitter.cpp b/lib/ObjectYAML/DWARFEmitter.cpp index 1e2e960b9dc..2c2d8958e53 100644 --- a/lib/ObjectYAML/DWARFEmitter.cpp +++ b/lib/ObjectYAML/DWARFEmitter.cpp @@ -24,14 +24,14 @@ using namespace llvm; template -void writeInteger(T Integer, raw_ostream &OS, bool IsLittleEndian) { +static void writeInteger(T Integer, raw_ostream &OS, bool IsLittleEndian) { if (IsLittleEndian != sys::IsLittleEndianHost) sys::swapByteOrder(Integer); OS.write(reinterpret_cast(&Integer), sizeof(T)); } -void writeVariableSizedInteger(uint64_t Integer, size_t Size, raw_ostream &OS, - bool IsLittleEndian) { +static void writeVariableSizedInteger(uint64_t Integer, size_t Size, + raw_ostream &OS, bool IsLittleEndian) { if (8 == Size) writeInteger((uint64_t)Integer, OS, IsLittleEndian); else if (4 == Size) @@ -44,7 +44,7 @@ void writeVariableSizedInteger(uint64_t Integer, size_t Size, raw_ostream &OS, assert(false && "Invalid integer write size."); } -void ZeroFillBytes(raw_ostream &OS, size_t Size) { +static void ZeroFillBytes(raw_ostream &OS, size_t Size) { std::vector FillData; FillData.insert(FillData.begin(), Size, 0); OS.write(reinterpret_cast(FillData.data()), Size); @@ -236,7 +236,7 @@ void DWARFYAML::EmitDebugInfo(raw_ostream &OS, const DWARFYAML::Data &DI) { } } -void EmitFileEntry(raw_ostream &OS, const DWARFYAML::File &File) { +static void EmitFileEntry(raw_ostream &OS, const DWARFYAML::File &File) { OS.write(File.Name.data(), File.Name.size()); OS.write('\0'); encodeULEB128(File.DirIdx, OS); @@ -245,7 +245,7 @@ void EmitFileEntry(raw_ostream &OS, const DWARFYAML::File &File) { } void DWARFYAML::EmitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) { - for (const auto LineTable : DI.DebugLines) { + for (const auto &LineTable : DI.DebugLines) { writeInteger((uint32_t)LineTable.TotalLength, OS, DI.IsLittleEndian); uint64_t SizeOfPrologueLength = 4; if (LineTable.TotalLength == UINT32_MAX) { @@ -333,9 +333,10 @@ void DWARFYAML::EmitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) { typedef void (*EmitFuncType)(raw_ostream &, const DWARFYAML::Data &); -void EmitDebugSectionImpl( - const DWARFYAML::Data &DI, EmitFuncType EmitFunc, StringRef Sec, - StringMap> &OutputBuffers) { +static void +EmitDebugSectionImpl(const DWARFYAML::Data &DI, EmitFuncType EmitFunc, + StringRef Sec, + StringMap> &OutputBuffers) { std::string Data; raw_string_ostream DebugInfoStream(Data); EmitFunc(DebugInfoStream, DI); diff --git a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp index 23bffb9bc01..22d99bfb371 100644 --- a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -101,10 +101,7 @@ StringRef Hexagon_MC::selectHexagonCPU(const Triple &TT, StringRef CPU) { return ArchV; } -unsigned HexagonGetLastSlot() { - return HexagonItinerariesV4FU::SLOT3; -} - +unsigned llvm::HexagonGetLastSlot() { return HexagonItinerariesV4FU::SLOT3; } namespace { diff --git a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h index 82758a92004..6bb69be6142 100644 --- a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h +++ b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h @@ -65,10 +65,11 @@ MCAsmBackend *createHexagonAsmBackend(const Target &T, MCObjectWriter *createHexagonELFObjectWriter(raw_pwrite_stream &OS, uint8_t OSABI, StringRef CPU); -} // End llvm namespace unsigned HexagonGetLastSlot(); +} // End llvm namespace + // Define symbolic names for Hexagon registers. This defines a mapping from // register name to register number. // diff --git a/lib/Target/PowerPC/PPCExpandISEL.cpp b/lib/Target/PowerPC/PPCExpandISEL.cpp index accb84a8094..ebd414baf1d 100644 --- a/lib/Target/PowerPC/PPCExpandISEL.cpp +++ b/lib/Target/PowerPC/PPCExpandISEL.cpp @@ -42,6 +42,7 @@ static cl::opt cl::desc("Enable generating the ISEL instruction."), cl::init(true), cl::Hidden); +namespace { class PPCExpandISEL : public MachineFunctionPass { DebugLoc dl; MachineFunction *MF; @@ -143,6 +144,7 @@ public: return true; } }; +} // end anonymous namespace void PPCExpandISEL::initialize(MachineFunction &MFParam) { MF = &MFParam; diff --git a/lib/Target/X86/X86InterleavedAccess.cpp b/lib/Target/X86/X86InterleavedAccess.cpp index d9edf4676fa..806d6cc888f 100644 --- a/lib/Target/X86/X86InterleavedAccess.cpp +++ b/lib/Target/X86/X86InterleavedAccess.cpp @@ -19,6 +19,7 @@ using namespace llvm; +namespace { /// \brief This class holds necessary information to represent an interleaved /// access group and supports utilities to lower the group into /// X86-specific instructions/intrinsics. @@ -27,7 +28,6 @@ using namespace llvm; /// %wide.vec = load <8 x i32>, <8 x i32>* %ptr /// %v0 = shuffle <8 x i32> %wide.vec, <8 x i32> undef, <0, 2, 4, 6> /// %v1 = shuffle <8 x i32> %wide.vec, <8 x i32> undef, <1, 3, 5, 7> - class X86InterleavedAccessGroup { /// \brief Reference to the wide-load instruction of an interleaved access /// group. @@ -95,6 +95,7 @@ public: /// instructions/intrinsics. bool lowerIntoOptimizedSequence(); }; +} // end anonymous namespace bool X86InterleavedAccessGroup::isSupported() const { VectorType *ShuffleVecTy = Shuffles[0]->getType(); diff --git a/lib/Transforms/Scalar/NewGVN.cpp b/lib/Transforms/Scalar/NewGVN.cpp index df8b5bf879e..e67cd1f2818 100644 --- a/lib/Transforms/Scalar/NewGVN.cpp +++ b/lib/Transforms/Scalar/NewGVN.cpp @@ -200,6 +200,7 @@ template <> struct DenseMapInfo { }; } // end namespace llvm +namespace { class NewGVN : public FunctionPass { DominatorTree *DT; const DataLayout *DL; @@ -380,6 +381,7 @@ private: void verifyMemoryCongruency() const; bool singleReachablePHIPath(const MemoryAccess *, const MemoryAccess *) const; }; +} // end anonymous namespace char NewGVN::ID = 0; @@ -749,15 +751,6 @@ const StoreExpression *NewGVN::createStoreExpression(StoreInst *SI, return E; } -// Utility function to check whether the congruence class has a member other -// than the given instruction. -bool hasMemberOtherThanUs(const CongruenceClass *CC, Instruction *I) { - // Either it has more than one store, in which case it must contain something - // other than us (because it's indexed by value), or if it only has one store - // right now, that member should not be us. - return CC->StoreCount > 1 || CC->Members.count(I) == 0; -} - const Expression *NewGVN::performSymbolicStoreEvaluation(Instruction *I) { // Unlike loads, we never try to eliminate stores, so we do not check if they // are simple and avoid value numbering them. diff --git a/lib/XRay/Trace.cpp b/lib/XRay/Trace.cpp index 51000c777de..6d5e4527683 100644 --- a/lib/XRay/Trace.cpp +++ b/lib/XRay/Trace.cpp @@ -24,8 +24,8 @@ using llvm::yaml::Input; using XRayRecordStorage = std::aligned_storage::type; -Error NaiveLogLoader(StringRef Data, XRayFileHeader &FileHeader, - std::vector &Records) { +static Error NaiveLogLoader(StringRef Data, XRayFileHeader &FileHeader, + std::vector &Records) { // FIXME: Maybe deduce whether the data is little or big-endian using some // magic bytes in the beginning of the file? @@ -98,8 +98,8 @@ Error NaiveLogLoader(StringRef Data, XRayFileHeader &FileHeader, return Error::success(); } -Error YAMLLogLoader(StringRef Data, XRayFileHeader &FileHeader, - std::vector &Records) { +static Error YAMLLogLoader(StringRef Data, XRayFileHeader &FileHeader, + std::vector &Records) { // Load the documents from the MappedFile. YAMLXRayTrace Trace;