[llvm] r185681 - Don't treat bitcode files specially in llvm-ar.

Rafael Espindola rafael.espindola at gmail.com
Thu Jul 4 21:19:32 PDT 2013


Author: rafael
Date: Thu Jul  4 23:19:32 2013
New Revision: 185681

URL: http://llvm.org/viewvc/llvm-project?rev=185681&view=rev
Log:
Don't treat bitcode files specially in llvm-ar.

We really want bitcode files to behave as regular object files in archives, so
we don't need to track that a member is bitcode.

Modified:
    llvm/trunk/tools/llvm-ar/Archive.cpp
    llvm/trunk/tools/llvm-ar/Archive.h
    llvm/trunk/tools/llvm-ar/ArchiveReader.cpp
    llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp

Modified: llvm/trunk/tools/llvm-ar/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/Archive.cpp?rev=185681&r1=185680&r2=185681&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/Archive.cpp (original)
+++ llvm/trunk/tools/llvm-ar/Archive.cpp Thu Jul  4 23:19:32 2013
@@ -125,13 +125,6 @@ bool ArchiveMember::replaceWith(StringRe
       return true;
   }
 
-  // Determine what kind of file it is.
-  if (sys::fs::identify_magic(StringRef(signature, 4)) ==
-      sys::fs::file_magic::bitcode)
-    flags |= BitcodeFlag;
-  else
-    flags &= ~BitcodeFlag;
-
   return false;
 }
 

Modified: llvm/trunk/tools/llvm-ar/Archive.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/Archive.h?rev=185681&r1=185680&r2=185681&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/Archive.h (original)
+++ llvm/trunk/tools/llvm-ar/Archive.h Thu Jul  4 23:19:32 2013
@@ -52,7 +52,6 @@ class ArchiveMember : public ilist_node<
     enum Flags {
       SVR4SymbolTableFlag = 1,     ///< Member is a SVR4 symbol table
       BSD4SymbolTableFlag = 2,     ///< Member is a BSD4 symbol table
-      BitcodeFlag         = 4,     ///< Member is bitcode
       HasLongFilenameFlag = 8,     ///< Member uses the long filename syntax
       StringTableFlag     = 16     ///< Member is an ar(1) format string table
     };
@@ -121,10 +120,6 @@ class ArchiveMember : public ilist_node<
     /// @brief Determine if this member is the ar(1) string table.
     bool isStringTable() const { return flags&StringTableFlag; }
 
-    /// @returns true iff the archive member is a bitcode file.
-    /// @brief Determine if this member is a bitcode file.
-    bool isBitcode() const { return flags&BitcodeFlag; }
-
     /// Long filenames are an artifact of the ar(1) file format which allows
     /// up to sixteen characters in its header and doesn't allow a path
     /// separator character (/). To avoid this, a "long format" member name is

Modified: llvm/trunk/tools/llvm-ar/ArchiveReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/ArchiveReader.cpp?rev=185681&r1=185680&r2=185681&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/ArchiveReader.cpp (original)
+++ llvm/trunk/tools/llvm-ar/ArchiveReader.cpp Thu Jul  4 23:19:32 2013
@@ -162,13 +162,6 @@ Archive::parseMemberHeader(const char*&
       break;
   }
 
-  // Determine if this is a bitcode file
-  if (sys::fs::identify_magic(StringRef(At, 4)) ==
-      sys::fs::file_magic::bitcode)
-    flags |= ArchiveMember::BitcodeFlag;
-  else
-    flags &= ~ArchiveMember::BitcodeFlag;
-
   // Instantiate the ArchiveMember to be filled
   ArchiveMember* member = new ArchiveMember(this);
 

Modified: llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp?rev=185681&r1=185680&r2=185681&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp (original)
+++ llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp Thu Jul  4 23:19:32 2013
@@ -183,13 +183,6 @@ bool Archive::addFileBefore(StringRef fi
   sys::fs::file_magic type;
   if (sys::fs::identify_magic(mbr->path, type))
     type = sys::fs::file_magic::unknown;
-  switch (type) {
-    case sys::fs::file_magic::bitcode:
-      flags |= ArchiveMember::BitcodeFlag;
-      break;
-    default:
-      break;
-  }
   mbr->flags = flags;
   members.insert(where,mbr);
   return false;

Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=185681&r1=185680&r2=185681&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Thu Jul  4 23:19:32 2013
@@ -99,7 +99,6 @@ bool AddBefore = false;          ///< 'b
 bool Create = false;             ///< 'c' modifier
 bool TruncateNames = false;      ///< 'f' modifier
 bool InsertBefore = false;       ///< 'i' modifier
-bool DontSkipBitcode = false;    ///< 'k' modifier
 bool UseCount = false;           ///< 'N' modifier
 bool OriginalDates = false;      ///< 'o' modifier
 bool FullPath = false;           ///< 'P' modifier
@@ -219,7 +218,6 @@ ArchiveOperation parseCommandLine() {
     case 'x': ++NumOperations; Operation = Extract; break;
     case 'c': Create = true; break;
     case 'f': TruncateNames = true; break;
-    case 'k': DontSkipBitcode = true; break;
     case 'l': /* accepted but unused */ break;
     case 'o': OriginalDates = true; break;
     case 's': break; // Ignore for now.
@@ -323,8 +321,7 @@ bool doPrint(std::string* ErrMsg) {
         const char* data = reinterpret_cast<const char*>(I->getData());
 
         // Skip things that don't make sense to print
-        if (I->isSVR4SymbolTable() ||
-            I->isBSD4SymbolTable() || (!DontSkipBitcode && I->isBitcode()))
+        if (I->isSVR4SymbolTable() || I->isBSD4SymbolTable())
           continue;
 
         if (Verbose)
@@ -373,10 +370,7 @@ doDisplayTable(std::string* ErrMsg) {
       if (Verbose) {
         // FIXME: Output should be this format:
         // Zrw-r--r--  500/ 500    525 Nov  8 17:42 2004 Makefile
-        if (I->isBitcode())
-          outs() << "b";
-        else
-          outs() << " ";
+        outs() << " ";
         unsigned mode = I->getMode();
         printMode((mode >> 6) & 007);
         printMode((mode >> 3) & 007);





More information about the llvm-commits mailing list