[lld] r189881 - [PECOFF] Allocate storage for .drective in the reader to avoid multiple calls of allocateString()

Rui Ueyama ruiu at google.com
Tue Sep 3 16:14:30 PDT 2013


Author: ruiu
Date: Tue Sep  3 18:14:30 2013
New Revision: 189881

URL: http://llvm.org/viewvc/llvm-project?rev=189881&view=rev
Log:
[PECOFF] Allocate storage for .drective in the reader to avoid multiple calls of allocateString()

Modified:
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=189881&r1=189880&r2=189881&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Sep  3 18:14:30 2013
@@ -350,12 +350,12 @@ bool WinLinkDriver::parse(int argc, cons
 
     case OPT_entry:
       // handle /entry
-      ctx.setEntrySymbolName(ctx.allocateString(inputArg->getValue()));
+      ctx.setEntrySymbolName(inputArg->getValue());
       break;
 
     case OPT_libpath:
       // handle /libpath
-      ctx.appendInputSearchPath(ctx.allocateString(inputArg->getValue()));
+      ctx.appendInputSearchPath(inputArg->getValue());
       break;
 
     case OPT_force:
@@ -410,12 +410,12 @@ bool WinLinkDriver::parse(int argc, cons
 
     case OPT_incl:
       // handle /incl
-      ctx.addInitialUndefinedSymbol(ctx.allocateString(inputArg->getValue()));
+      ctx.addInitialUndefinedSymbol(inputArg->getValue());
       break;
 
     case OPT_out:
       // handle /out
-      ctx.setOutputPath(ctx.allocateString(inputArg->getValue()));
+      ctx.setOutputPath(inputArg->getValue());
       break;
 
     case OPT_INPUT:

Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=189881&r1=189880&r2=189881&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Tue Sep  3 18:14:30 2013
@@ -112,7 +112,7 @@ private:
   SectionToAtomsT;
 
 public:
-  FileCOFF(const LinkingContext &context,
+  FileCOFF(const PECOFFLinkingContext &context,
            std::unique_ptr<llvm::MemoryBuffer> mb, error_code &ec)
       : File(mb->getBufferIdentifier(), kindObject), _context(context) {
     llvm::OwningPtr<llvm::object::Binary> bin;
@@ -602,7 +602,7 @@ private:
       ArrayRef<uint8_t> contents;
       if (error_code ec = _obj->getSectionContents(section, contents))
         return ec;
-      _directives = std::move(ArrayRefToString(contents));
+      _directives = _context.allocateString(ArrayRefToString(contents));
     }
     return error_code::success();
   }
@@ -614,7 +614,7 @@ private:
   atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
 
   // The contents of .drectve section.
-  std::string _directives;
+  StringRef _directives;
 
   // A map from symbol to its name. All symbols should be in this map except
   // unnamed ones.
@@ -638,7 +638,7 @@ private:
            std::map<uint32_t, COFFDefinedAtom *>> _definedAtomLocations;
 
   mutable llvm::BumpPtrAllocator _alloc;
-  const LinkingContext &_context;
+  const PECOFFLinkingContext &_context;
 };
 
 class BumpPtrStringSaver : public llvm::cl::StringSaver {
@@ -714,7 +714,8 @@ private:
                            std::vector<std::unique_ptr<File>> &result) const {
     // Parse the memory buffer as PECOFF file.
     error_code ec;
-    std::unique_ptr<FileCOFF> file(new FileCOFF(_context, std::move(mb), ec));
+    std::unique_ptr<FileCOFF> file(
+        new FileCOFF(_PECOFFLinkingContext, std::move(mb), ec));
     if (ec)
       return ec;
 





More information about the llvm-commits mailing list