[lld] r298323 - Move OffsetInArchive to BitcodeFile.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 20 16:47:06 PDT 2017


Author: rafael
Date: Mon Mar 20 18:47:06 2017
New Revision: 298323

URL: http://llvm.org/viewvc/llvm-project?rev=298323&view=rev
Log:
Move OffsetInArchive to BitcodeFile.

It is the only file type that needs it.

Modified:
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/ELF/InputFiles.h

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=298323&r1=298322&r2=298323&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Mon Mar 20 18:47:06 2017
@@ -767,7 +767,8 @@ static uint8_t getBitcodeMachineKind(Mem
   }
 }
 
-BitcodeFile::BitcodeFile(MemoryBufferRef MB) : InputFile(BitcodeKind, MB) {
+BitcodeFile::BitcodeFile(MemoryBufferRef MB, uint64_t OffsetInArchive)
+    : InputFile(BitcodeKind, MB), OffsetInArchive(OffsetInArchive) {
   EKind = getBitcodeELFKind(MB);
   EMachine = getBitcodeMachineKind(MB);
 }
@@ -905,10 +906,9 @@ static bool isBitcode(MemoryBufferRef MB
 
 InputFile *elf::createObjectFile(MemoryBufferRef MB, StringRef ArchiveName,
                                  uint64_t OffsetInArchive) {
-  InputFile *F =
-      isBitcode(MB) ? make<BitcodeFile>(MB) : createELFFile<ObjectFile>(MB);
+  InputFile *F = isBitcode(MB) ? make<BitcodeFile>(MB, OffsetInArchive)
+                               : createELFFile<ObjectFile>(MB);
   F->ArchiveName = ArchiveName;
-  F->OffsetInArchive = OffsetInArchive;
   return F;
 }
 

Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=298323&r1=298322&r2=298323&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Mon Mar 20 18:47:06 2017
@@ -79,12 +79,6 @@ public:
   // string for creating error messages.
   StringRef ArchiveName;
 
-  // If this file is in an archive, the member contains the offset of
-  // the file in the archive. Otherwise, it's just zero. We store this
-  // field so that we can pass it to lib/LTO in order to disambiguate
-  // between objects.
-  uint64_t OffsetInArchive;
-
   // If this is an architecture-specific file, the following members
   // have ELF type (i.e. ELF{32,64}{LE,BE}) and target machine type.
   ELFKind EKind = ELFNoneKind;
@@ -255,13 +249,19 @@ private:
 
 class BitcodeFile : public InputFile {
 public:
-  explicit BitcodeFile(MemoryBufferRef M);
+  BitcodeFile(MemoryBufferRef M, uint64_t OffsetInArchive);
   static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
   template <class ELFT>
   void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
   ArrayRef<Symbol *> getSymbols() { return Symbols; }
   std::unique_ptr<llvm::lto::InputFile> Obj;
 
+  // If this file is in an archive, the member contains the offset of
+  // the file in the archive. Otherwise, it's just zero. We store this
+  // field so that we can pass it to lib/LTO in order to disambiguate
+  // between objects.
+  uint64_t OffsetInArchive;
+
 private:
   std::vector<Symbol *> Symbols;
 };




More information about the llvm-commits mailing list