diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-29 16:25:25 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-29 16:25:25 +0000 |
commit | ab44ce3d598882e51a25eb82eb7ae6308de85ae6 (patch) | |
tree | 568d786a59d49bef961dcb9bd09d422701b9da5b /lib/Support | |
parent | b5630dbadf9a2a06754194387d6b0fd9962a67f1 (diff) |
Notes
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/APInt.cpp | 4 | ||||
-rw-r--r-- | lib/Support/BinaryStreamReader.cpp | 27 | ||||
-rw-r--r-- | lib/Support/ConvertUTF.cpp | 31 | ||||
-rw-r--r-- | lib/Support/DebugCounter.cpp | 2 | ||||
-rw-r--r-- | lib/Support/DynamicLibrary.cpp | 11 | ||||
-rw-r--r-- | lib/Support/GraphWriter.cpp | 1 | ||||
-rw-r--r-- | lib/Support/Host.cpp | 1 | ||||
-rw-r--r-- | lib/Support/Path.cpp | 1 | ||||
-rw-r--r-- | lib/Support/Triple.cpp | 17 | ||||
-rw-r--r-- | lib/Support/YAMLParser.cpp | 4 |
10 files changed, 79 insertions, 20 deletions
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index 2a916b14bc22b..e9716e3b1e872 100644 --- a/lib/Support/APInt.cpp +++ b/lib/Support/APInt.cpp @@ -2045,7 +2045,7 @@ void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix, if (isSingleWord()) { char Buffer[65]; - char *BufPtr = Buffer+65; + char *BufPtr = std::end(Buffer); uint64_t N; if (!Signed) { @@ -2069,7 +2069,7 @@ void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix, *--BufPtr = Digits[N % Radix]; N /= Radix; } - Str.append(BufPtr, Buffer+65); + Str.append(BufPtr, std::end(Buffer)); return; } diff --git a/lib/Support/BinaryStreamReader.cpp b/lib/Support/BinaryStreamReader.cpp index 5c277448a7655..862232971162c 100644 --- a/lib/Support/BinaryStreamReader.cpp +++ b/lib/Support/BinaryStreamReader.cpp @@ -42,29 +42,30 @@ Error BinaryStreamReader::readBytes(ArrayRef<uint8_t> &Buffer, uint32_t Size) { } Error BinaryStreamReader::readCString(StringRef &Dest) { - // TODO: This could be made more efficient by using readLongestContiguousChunk - // and searching for null terminators in the resulting buffer. - - uint32_t Length = 0; - // First compute the length of the string by reading 1 byte at a time. uint32_t OriginalOffset = getOffset(); - const char *C; + uint32_t FoundOffset = 0; while (true) { - if (auto EC = readObject(C)) + uint32_t ThisOffset = getOffset(); + ArrayRef<uint8_t> Buffer; + if (auto EC = readLongestContiguousChunk(Buffer)) return EC; - if (*C == '\0') + StringRef S(reinterpret_cast<const char *>(Buffer.begin()), Buffer.size()); + size_t Pos = S.find_first_of('\0'); + if (LLVM_LIKELY(Pos != StringRef::npos)) { + FoundOffset = Pos + ThisOffset; break; - ++Length; + } } - // Now go back and request a reference for that many bytes. - uint32_t NewOffset = getOffset(); + assert(FoundOffset >= OriginalOffset); + setOffset(OriginalOffset); + size_t Length = FoundOffset - OriginalOffset; if (auto EC = readFixedString(Dest, Length)) return EC; - // Now set the offset back to where it was after we calculated the length. - setOffset(NewOffset); + // Now set the offset back to after the null terminator. + setOffset(FoundOffset + 1); return Error::success(); } diff --git a/lib/Support/ConvertUTF.cpp b/lib/Support/ConvertUTF.cpp index 39fd218d3f071..aa9507c189eda 100644 --- a/lib/Support/ConvertUTF.cpp +++ b/lib/Support/ConvertUTF.cpp @@ -53,6 +53,35 @@ #endif #include <assert.h> + +/* + * This code extensively uses fall-through switches. + * Keep the compiler from warning about that. + */ +#if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wimplicit-fallthrough") +# define ConvertUTF_DISABLE_WARNINGS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wimplicit-fallthrough\"") +# define ConvertUTF_RESTORE_WARNINGS \ + _Pragma("clang diagnostic pop") +# endif +#elif defined(__GNUC__) && __GNUC__ > 6 +# define ConvertUTF_DISABLE_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") +# define ConvertUTF_RESTORE_WARNINGS \ + _Pragma("GCC diagnostic pop") +#endif +#ifndef ConvertUTF_DISABLE_WARNINGS +# define ConvertUTF_DISABLE_WARNINGS +#endif +#ifndef ConvertUTF_RESTORE_WARNINGS +# define ConvertUTF_RESTORE_WARNINGS +#endif + +ConvertUTF_DISABLE_WARNINGS + namespace llvm { static const int halfShift = 10; /* used for shifting by 10 bits */ @@ -708,3 +737,5 @@ ConversionResult ConvertUTF8toUTF32(const UTF8 **sourceStart, --------------------------------------------------------------------- */ } // namespace llvm + +ConvertUTF_RESTORE_WARNINGS diff --git a/lib/Support/DebugCounter.cpp b/lib/Support/DebugCounter.cpp index 29dae8a20f00f..a10ac8e853966 100644 --- a/lib/Support/DebugCounter.cpp +++ b/lib/Support/DebugCounter.cpp @@ -6,6 +6,7 @@ using namespace llvm; +namespace { // This class overrides the default list implementation of printing so we // can pretty print the list of debug counter options. This type of // dynamic option is pretty rare (basically this and pass lists). @@ -40,6 +41,7 @@ private: } } }; +} // namespace // Create our command line option. static DebugCounterList DebugCounterOption( diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp index 1541a5726302e..9398789cea871 100644 --- a/lib/Support/DynamicLibrary.cpp +++ b/lib/Support/DynamicLibrary.cpp @@ -127,10 +127,15 @@ void DynamicLibrary::AddSymbol(StringRef SymbolName, void *SymbolValue) { DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *FileName, std::string *Err) { - SmartScopedLock<true> Lock(*SymbolsMutex); + // Force OpenedHandles to be added into the ManagedStatic list before any + // ManagedStatic can be added from static constructors in HandleSet::DLOpen. + HandleSet& HS = *OpenedHandles; + void *Handle = HandleSet::DLOpen(FileName, Err); - if (Handle != &Invalid) - OpenedHandles->AddLibrary(Handle, /*IsProcess*/ FileName == nullptr); + if (Handle != &Invalid) { + SmartScopedLock<true> Lock(*SymbolsMutex); + HS.AddLibrary(Handle, /*IsProcess*/ FileName == nullptr); + } return DynamicLibrary(Handle); } diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp index d0e1d50e8ccbc..f70b77da8de47 100644 --- a/lib/Support/GraphWriter.cpp +++ b/lib/Support/GraphWriter.cpp @@ -43,6 +43,7 @@ std::string llvm::DOT::EscapeString(const std::string &Label) { Str.erase(Str.begin()+i); continue; default: break; } + LLVM_FALLTHROUGH; case '{': case '}': case '<': case '>': case '|': case '"': diff --git a/lib/Support/Host.cpp b/lib/Support/Host.cpp index 6a0b64fb884df..234f7439a546b 100644 --- a/lib/Support/Host.cpp +++ b/lib/Support/Host.cpp @@ -1401,6 +1401,7 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) { Features["prefetchwt1"] = HasLeaf7 && (ECX & 1); Features["avx512vbmi"] = HasLeaf7 && ((ECX >> 1) & 1) && HasAVX512Save; + Features["avx512vpopcntdq"] = HasLeaf7 && ((ECX >> 14) & 1) && HasAVX512Save; // Enable protection keys Features["pku"] = HasLeaf7 && ((ECX >> 4) & 1); diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 9fd6652ce4b8c..80bef558258db 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -1156,6 +1156,7 @@ file_magic identify_magic(StringRef Magic) { case 0xc4: // ARMNT Windows if (Magic[1] == 0x01) return file_magic::coff_object; + LLVM_FALLTHROUGH; case 0x90: // PA-RISC Windows case 0x68: // mc68K Windows diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index b0e3d6898cae0..318e21da999d9 100644 --- a/lib/Support/Triple.cpp +++ b/lib/Support/Triple.cpp @@ -34,6 +34,7 @@ StringRef Triple::getArchTypeName(ArchType Kind) { case mips64: return "mips64"; case mips64el: return "mips64el"; case msp430: return "msp430"; + case nios2: return "nios2"; case ppc64: return "powerpc64"; case ppc64le: return "powerpc64le"; case ppc: return "powerpc"; @@ -98,6 +99,8 @@ StringRef Triple::getArchTypePrefix(ArchType Kind) { case mips64: case mips64el: return "mips"; + case nios2: return "nios2"; + case hexagon: return "hexagon"; case amdgcn: return "amdgcn"; @@ -262,6 +265,7 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) { .Case("mips64", mips64) .Case("mips64el", mips64el) .Case("msp430", msp430) + .Case("nios2", nios2) .Case("ppc64", ppc64) .Case("ppc32", ppc) .Case("ppc", ppc) @@ -384,6 +388,7 @@ static Triple::ArchType parseArch(StringRef ArchName) { .Cases("mipsel", "mipsallegrexel", Triple::mipsel) .Cases("mips64", "mips64eb", Triple::mips64) .Case("mips64el", Triple::mips64el) + .Case("nios2", Triple::nios2) .Case("r600", Triple::r600) .Case("amdgcn", Triple::amdgcn) .Case("riscv32", Triple::riscv32) @@ -625,6 +630,7 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) { case Triple::mips64el: case Triple::mipsel: case Triple::msp430: + case Triple::nios2: case Triple::nvptx: case Triple::nvptx64: case Triple::ppc64le: @@ -643,11 +649,13 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) { case Triple::tce: case Triple::tcele: case Triple::thumbeb: - case Triple::wasm32: - case Triple::wasm64: case Triple::xcore: return Triple::ELF; + case Triple::wasm32: + case Triple::wasm64: + return Triple::Wasm; + case Triple::ppc: case Triple::ppc64: if (T.isOSDarwin()) @@ -1160,6 +1168,7 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) { case llvm::Triple::le32: case llvm::Triple::mips: case llvm::Triple::mipsel: + case llvm::Triple::nios2: case llvm::Triple::nvptx: case llvm::Triple::ppc: case llvm::Triple::r600: @@ -1243,6 +1252,7 @@ Triple Triple::get32BitArchVariant() const { case Triple::le32: case Triple::mips: case Triple::mipsel: + case Triple::nios2: case Triple::nvptx: case Triple::ppc: case Triple::r600: @@ -1290,6 +1300,7 @@ Triple Triple::get64BitArchVariant() const { case Triple::kalimba: case Triple::lanai: case Triple::msp430: + case Triple::nios2: case Triple::r600: case Triple::tce: case Triple::tcele: @@ -1361,6 +1372,7 @@ Triple Triple::getBigEndianArchVariant() const { case Triple::le32: case Triple::le64: case Triple::msp430: + case Triple::nios2: case Triple::nvptx64: case Triple::nvptx: case Triple::r600: @@ -1447,6 +1459,7 @@ bool Triple::isLittleEndian() const { case Triple::mips64el: case Triple::mipsel: case Triple::msp430: + case Triple::nios2: case Triple::nvptx64: case Triple::nvptx: case Triple::ppc64le: diff --git a/lib/Support/YAMLParser.cpp b/lib/Support/YAMLParser.cpp index c17a6f6e1ea63..f1496393e55e4 100644 --- a/lib/Support/YAMLParser.cpp +++ b/lib/Support/YAMLParser.cpp @@ -2116,6 +2116,7 @@ void MappingNode::increment() { break; default: setError("Unexpected token. Expected Key or Block End", T); + LLVM_FALLTHROUGH; case Token::TK_Error: IsAtEnd = true; CurrentEntry = nullptr; @@ -2128,6 +2129,7 @@ void MappingNode::increment() { return increment(); case Token::TK_FlowMappingEnd: getNext(); + LLVM_FALLTHROUGH; case Token::TK_Error: // Set this to end iterator. IsAtEnd = true; @@ -2170,6 +2172,7 @@ void SequenceNode::increment() { default: setError( "Unexpected token. Expected Block Entry or Block End." , T); + LLVM_FALLTHROUGH; case Token::TK_Error: IsAtEnd = true; CurrentEntry = nullptr; @@ -2198,6 +2201,7 @@ void SequenceNode::increment() { return increment(); case Token::TK_FlowSequenceEnd: getNext(); + LLVM_FALLTHROUGH; case Token::TK_Error: // Set this to end iterator. IsAtEnd = true; |