Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit d681e31

Browse files
committed
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211207 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent cc21bbd commit d681e31

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/Object/IRObjectFile.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ using namespace object;
2323
IRObjectFile::IRObjectFile(MemoryBuffer *Object, std::error_code &EC,
2424
LLVMContext &Context, bool BufferOwned)
2525
: SymbolicFile(Binary::ID_IR, Object, BufferOwned) {
26-
ErrorOr<Module*> MOrErr = parseBitcodeFile(Object, Context);
26+
ErrorOr<Module *> MOrErr =
27+
getLazyBitcodeModule(Object, Context, /*BufferOwned*/ false);
2728
if ((EC = MOrErr.getError()))
2829
return;
2930

@@ -104,11 +105,21 @@ std::error_code IRObjectFile::printSymbolName(raw_ostream &OS,
104105
return object_error::success;
105106
}
106107

108+
static bool isDeclaration(const GlobalValue &V) {
109+
if (V.hasAvailableExternallyLinkage())
110+
return true;
111+
112+
if (V.isMaterializable())
113+
return false;
114+
115+
return V.isDeclaration();
116+
}
117+
107118
uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const {
108119
const GlobalValue &GV = getGV(Symb);
109120

110121
uint32_t Res = BasicSymbolRef::SF_None;
111-
if (GV.isDeclaration() || GV.hasAvailableExternallyLinkage())
122+
if (isDeclaration(GV))
112123
Res |= BasicSymbolRef::SF_Undefined;
113124
if (GV.hasPrivateLinkage())
114125
Res |= BasicSymbolRef::SF_FormatSpecific;

0 commit comments

Comments
 (0)