[lld] r240982 - [opt] Hoist the call throuh SymbolBody::getReplacement out of the inline
Chandler Carruth
chandlerc at gmail.com
Mon Jun 29 11:50:12 PDT 2015
Author: chandlerc
Date: Mon Jun 29 13:50:11 2015
New Revision: 240982
URL: http://llvm.org/viewvc/llvm-project?rev=240982&view=rev
Log:
[opt] Hoist the call throuh SymbolBody::getReplacement out of the inline
method to get a SymbolBody and into the callers, and kill now dead
includes.
This removes the need to have the SymbolBody definition when we're
defining the inline method and makes it a better inline method. That was
the only reason for a lot of header includes here. Removing these and
using forward declarations actually uncovers a bunch of cross-header
dependencies that I've fixed while I'm here, and will allow me to
introduce some *important* inline code into Chunks.h that requires the
definition of ObjectFile.
No functionality changed at this point.
Differential Revision: http://reviews.llvm.org/D10789
Modified:
lld/trunk/COFF/Chunks.cpp
lld/trunk/COFF/InputFiles.h
lld/trunk/COFF/SymbolTable.cpp
lld/trunk/COFF/SymbolTable.h
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=240982&r1=240981&r2=240982&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Mon Jun 29 13:50:11 2015
@@ -58,7 +58,8 @@ void SectionChunk::writeTo(uint8_t *Buf)
// Apply relocations.
for (const coff_relocation &Rel : Relocs) {
uint8_t *Off = Buf + FileOff + Rel.VirtualAddress;
- SymbolBody *Body = File->getSymbolBody(Rel.SymbolTableIndex);
+ SymbolBody *Body =
+ File->getSymbolBody(Rel.SymbolTableIndex)->getReplacement();
uint64_t S = cast<Defined>(Body)->getRVA();
uint64_t P = RVA + Rel.VirtualAddress;
switch (Rel.Type) {
@@ -85,7 +86,7 @@ void SectionChunk::mark() {
// Mark all symbols listed in the relocation table for this section.
for (const coff_relocation &Rel : Relocs) {
- SymbolBody *B = File->getSymbolBody(Rel.SymbolTableIndex);
+ SymbolBody *B = File->getSymbolBody(Rel.SymbolTableIndex)->getReplacement();
if (auto *D = dyn_cast<DefinedRegular>(B))
D->markLive();
}
@@ -114,7 +115,8 @@ void SectionChunk::getBaserels(std::vect
// address never changes even if image is relocated.
if (Rel.Type != IMAGE_REL_AMD64_ADDR64)
continue;
- SymbolBody *Body = File->getSymbolBody(Rel.SymbolTableIndex);
+ SymbolBody *Body =
+ File->getSymbolBody(Rel.SymbolTableIndex)->getReplacement();
if (Body == ImageBase)
continue;
Res->push_back(RVA + Rel.VirtualAddress);
@@ -186,8 +188,9 @@ bool SectionChunk::equals(const SectionC
return false;
if (R1.VirtualAddress != R2.VirtualAddress)
return false;
- SymbolBody *B1 = File->getSymbolBody(R1.SymbolTableIndex);
- SymbolBody *B2 = X->File->getSymbolBody(R2.SymbolTableIndex);
+ SymbolBody *B1 = File->getSymbolBody(R1.SymbolTableIndex)->getReplacement();
+ SymbolBody *B2 =
+ X->File->getSymbolBody(R2.SymbolTableIndex)->getReplacement();
if (B1 == B2)
return true;
auto *D1 = dyn_cast<DefinedRegular>(B1);
Modified: lld/trunk/COFF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.h?rev=240982&r1=240981&r2=240982&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.h (original)
+++ lld/trunk/COFF/InputFiles.h Mon Jun 29 13:50:11 2015
@@ -10,8 +10,6 @@
#ifndef LLD_COFF_INPUT_FILES_H
#define LLD_COFF_INPUT_FILES_H
-#include "Chunks.h"
-#include "Symbols.h"
#include "lld/Core/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/LTO/LTOModule.h"
@@ -28,6 +26,10 @@ namespace coff {
using llvm::LTOModule;
using llvm::object::Archive;
using llvm::object::COFFObjectFile;
+using llvm::object::COFFSymbolRef;
+
+class Chunk;
+class SymbolBody;
// The root class of input files.
class InputFile {
@@ -102,7 +104,7 @@ public:
// Returns a SymbolBody object for the SymbolIndex'th symbol in the
// underlying object file.
SymbolBody *getSymbolBody(uint32_t SymbolIndex) {
- return SparseSymbolBodies[SymbolIndex]->getReplacement();
+ return SparseSymbolBodies[SymbolIndex];
}
// Returns the underying COFF file.
Modified: lld/trunk/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=240982&r1=240981&r2=240982&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.cpp (original)
+++ lld/trunk/COFF/SymbolTable.cpp Mon Jun 29 13:50:11 2015
@@ -11,6 +11,7 @@
#include "Driver.h"
#include "Error.h"
#include "SymbolTable.h"
+#include "Symbols.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/LTO/LTOCodeGenerator.h"
#include "llvm/Support/Debug.h"
Modified: lld/trunk/COFF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.h?rev=240982&r1=240981&r2=240982&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.h (original)
+++ lld/trunk/COFF/SymbolTable.h Mon Jun 29 13:50:11 2015
@@ -23,6 +23,12 @@ struct LTOCodeGenerator;
namespace lld {
namespace coff {
+class Chunk;
+class Defined;
+class Lazy;
+class SymbolBody;
+struct Symbol;
+
// SymbolTable is a bucket of all known symbols, including defined,
// undefined, or lazy symbols (the last one is symbols in archive
// files whose archive members are not yet loaded).
More information about the llvm-commits
mailing list