[llvm] r211207 - Change IRObjectFile to parse the bitcode lazily.

Rafael Espindola rafael.espindola at gmail.com
Wed Jun 18 12:05:24 PDT 2014


Author: rafael
Date: Wed Jun 18 14:05:24 2014
New Revision: 211207

URL: http://llvm.org/viewvc/llvm-project?rev=211207&view=rev
Log:
Change IRObjectFile to parse the bitcode lazily.

The main point of this class is to provide a cheap object interface to a bitcode
file, so it has to be as lazy as possible.

Modified:
    llvm/trunk/lib/Object/IRObjectFile.cpp

Modified: llvm/trunk/lib/Object/IRObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=211207&r1=211206&r2=211207&view=diff
==============================================================================
--- llvm/trunk/lib/Object/IRObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/IRObjectFile.cpp Wed Jun 18 14:05:24 2014
@@ -23,7 +23,8 @@ using namespace object;
 IRObjectFile::IRObjectFile(MemoryBuffer *Object, std::error_code &EC,
                            LLVMContext &Context, bool BufferOwned)
     : SymbolicFile(Binary::ID_IR, Object, BufferOwned) {
-  ErrorOr<Module*> MOrErr = parseBitcodeFile(Object, Context);
+  ErrorOr<Module *> MOrErr =
+      getLazyBitcodeModule(Object, Context, /*BufferOwned*/ false);
   if ((EC = MOrErr.getError()))
     return;
 
@@ -104,11 +105,21 @@ std::error_code IRObjectFile::printSymbo
   return object_error::success;
 }
 
+static bool isDeclaration(const GlobalValue &V) {
+  if (V.hasAvailableExternallyLinkage())
+    return true;
+
+  if (V.isMaterializable())
+    return false;
+
+  return V.isDeclaration();
+}
+
 uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const {
   const GlobalValue &GV = getGV(Symb);
 
   uint32_t Res = BasicSymbolRef::SF_None;
-  if (GV.isDeclaration() || GV.hasAvailableExternallyLinkage())
+  if (isDeclaration(GV))
     Res |= BasicSymbolRef::SF_Undefined;
   if (GV.hasPrivateLinkage())
     Res |= BasicSymbolRef::SF_FormatSpecific;





More information about the llvm-commits mailing list