summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/IRObjectFile.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-06-18 19:05:24 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-06-18 19:05:24 +0000
commit8af5cb2c282456ed24af65841fa0840f22df717f (patch)
treeb7b3e07677dcaa348459706467e0aaf46a196d97 /llvm/lib/Object/IRObjectFile.cpp
parent868050a667ee360c3d0f8e0345390839d1a23c4b (diff)
downloadbcm5719-llvm-8af5cb2c282456ed24af65841fa0840f22df717f.tar.gz
bcm5719-llvm-8af5cb2c282456ed24af65841fa0840f22df717f.zip
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. llvm-svn: 211207
Diffstat (limited to 'llvm/lib/Object/IRObjectFile.cpp')
-rw-r--r--llvm/lib/Object/IRObjectFile.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp
index 48820361d4f..004d8de065d 100644
--- a/llvm/lib/Object/IRObjectFile.cpp
+++ b/llvm/lib/Object/IRObjectFile.cpp
@@ -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::printSymbolName(raw_ostream &OS,
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;
OpenPOWER on IntegriCloud