[lld] r193762 - Revert "[PECOFF] Add atoms to the PassManager file"

Rui Ueyama ruiu at google.com
Thu Oct 31 09:59:49 PDT 2013


Author: ruiu
Date: Thu Oct 31 11:59:49 2013
New Revision: 193762

URL: http://llvm.org/viewvc/llvm-project?rev=193762&view=rev
Log:
Revert "[PECOFF] Add atoms to the PassManager file"

This reverts commit r193479.

The atoms are already added to the file, so re-adding them caused the YAML
writer to write the same atoms twice. That made the YAML reader to fail with
"duplicate atom name" error.

This is not the only error we've got for RoundTripYAMLPass for PECOFF, so we
cannot enable the test yet. More fixes will come.

Differential Revision: http://llvm-reviews.chandlerc.com/D2069

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp

Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h?rev=193762&r1=193761&r2=193762&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h Thu Oct 31 11:59:49 2013
@@ -265,20 +265,13 @@ public:
       createImportDirectory(context, loadName, atoms);
     }
 
-    auto nidatom = new (_alloc) NullImportDirectoryAtom(context);
-    context.file.addAtom(*nidatom);
+    // All atoms, including those of tyep NullImportDirectoryAtom, are added to
+    // context.file in the IdataAtom's constructor.
+    new (_alloc) NullImportDirectoryAtom(context);
 
     connectAtoms(context);
     createDataDirectoryAtoms(context);
     replaceSharedLibraryAtoms(context);
-    for (auto id : context.importDirectories)
-      context.file.addAtom(*id);
-    for (auto ilt : context.importLookupTables)
-      context.file.addAtom(*ilt);
-    for (auto iat : context.importAddressTables)
-      context.file.addAtom(*iat);
-    for (auto hna : context.hintNameAtoms)
-      context.file.addAtom(*hna);
   }
 
 private:
@@ -314,7 +307,6 @@ private:
     appendAtoms(atoms, context.importAddressTables);
     appendAtoms(atoms, context.dllNameAtoms);
     appendAtoms(atoms, context.hintNameAtoms);
-
     coff::connectAtomsWithLayoutEdge(atoms);
   }
 

Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=193762&r1=193761&r2=193762&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Thu Oct 31 11:59:49 2013
@@ -802,6 +802,19 @@ public:
       : _PECOFFLinkingContext(context), _numSections(0),
         _imageSizeInMemory(PAGE_SIZE), _imageSizeOnDisk(0) {}
 
+  // Make sure there are no duplicate atoms in the file. RoundTripYAMLPass also
+  // fails if there are duplicate atoms. This is a temporary measure until we
+  // enable the pass for PECOFF port.
+  void verifyFile(const File &linkedFile) {
+#ifndef NDEBUG
+    std::set<const DefinedAtom *> set;
+    for (const DefinedAtom *atom : linkedFile.defined()) {
+      assert(set.count(atom) == 0);
+      set.insert(atom);
+    }
+#endif
+  }
+
   // Create all chunks that consist of the output file.
   void build(const File &linkedFile) {
     // Create file chunks and add them to the list.
@@ -872,6 +885,7 @@ public:
   }
 
   virtual error_code writeFile(const File &linkedFile, StringRef path) {
+    verifyFile(linkedFile);
     this->build(linkedFile);
 
     uint64_t totalSize = _chunks.back()->fileOffset() + _chunks.back()->size();





More information about the llvm-commits mailing list