[lld] 7fe13af - Nit: Use early return to reduce indentation.
Luqman Aden via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 14 19:37:27 PDT 2020
Author: Luqman Aden
Date: 2020-10-14T19:34:32-07:00
New Revision: 7fe13af676678815989a6d0ece684687953245e7
URL: https://github.com/llvm/llvm-project/commit/7fe13af676678815989a6d0ece684687953245e7
DIFF: https://github.com/llvm/llvm-project/commit/7fe13af676678815989a6d0ece684687953245e7.diff
LOG: Nit: Use early return to reduce indentation.
Added:
Modified:
lld/COFF/Writer.cpp
Removed:
################################################################################
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index ba8f502ea81c..a40ff42683ee 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -2051,32 +2051,31 @@ PartialSection *Writer::findPartialSection(StringRef name, uint32_t outChars) {
}
void Writer::fixTlsAlignment() {
- if (Symbol *sym = symtab->findUnderscore("_tls_used")) {
- if (Defined *b = dyn_cast<Defined>(sym)) {
- OutputSection *sec = b->getChunk()->getOutputSection();
- assert(sec && b->getRVA() >= sec->getRVA() &&
- "no output section for _tls_used");
-
- uint8_t *secBuf = buffer->getBufferStart() + sec->getFileOff();
- uint64_t tlsOffset = b->getRVA() - sec->getRVA();
- uint64_t directorySize = config->is64()
- ? sizeof(object::coff_tls_directory64)
- : sizeof(object::coff_tls_directory32);
-
- if (tlsOffset + directorySize > sec->getRawSize())
- fatal("_tls_used is malformed");
-
- if (config->is64()) {
- object::coff_tls_directory64 *tlsDir =
- reinterpret_cast<object::coff_tls_directory64 *>(
- &secBuf[tlsOffset]);
- tlsDir->setAlignment(tlsAlignment);
- } else {
- object::coff_tls_directory32 *tlsDir =
- reinterpret_cast<object::coff_tls_directory32 *>(
- &secBuf[tlsOffset]);
- tlsDir->setAlignment(tlsAlignment);
- }
- }
+ Defined *tlsSym =
+ dyn_cast_or_null<Defined>(symtab->findUnderscore("_tls_used"));
+ if (!tlsSym)
+ return;
+
+ OutputSection *sec = tlsSym->getChunk()->getOutputSection();
+ assert(sec && tlsSym->getRVA() >= sec->getRVA() &&
+ "no output section for _tls_used");
+
+ uint8_t *secBuf = buffer->getBufferStart() + sec->getFileOff();
+ uint64_t tlsOffset = tlsSym->getRVA() - sec->getRVA();
+ uint64_t directorySize = config->is64()
+ ? sizeof(object::coff_tls_directory64)
+ : sizeof(object::coff_tls_directory32);
+
+ if (tlsOffset + directorySize > sec->getRawSize())
+ fatal("_tls_used is malformed");
+
+ if (config->is64()) {
+ object::coff_tls_directory64 *tlsDir =
+ reinterpret_cast<object::coff_tls_directory64 *>(&secBuf[tlsOffset]);
+ tlsDir->setAlignment(tlsAlignment);
+ } else {
+ object::coff_tls_directory32 *tlsDir =
+ reinterpret_cast<object::coff_tls_directory32 *>(&secBuf[tlsOffset]);
+ tlsDir->setAlignment(tlsAlignment);
}
-}
\ No newline at end of file
+}
More information about the llvm-commits
mailing list