mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-20 12:56:35 +00:00
Remove the IsStreamed member variable.
Having different code paths for streamed and regular bitcode reading was a source of bugs in the past and this defines them away. It has a small but noticeable impact on performance. I timed running "opt -disable-output -disable-verify" on a ltoed clang. It goes from 14.752845231 seconds time elapsed ( +- 0.16% ) to 15.012463721 seconds time elapsed ( +- 0.11% ) Extracted from a patch by Karl Schimpf. llvm-svn: 240305
This commit is contained in:
parent
6f567a4b79
commit
1c863ca3ea
@ -136,7 +136,6 @@ class BitcodeReader : public GVMaterializer {
|
|||||||
std::unique_ptr<MemoryBuffer> Buffer;
|
std::unique_ptr<MemoryBuffer> Buffer;
|
||||||
std::unique_ptr<BitstreamReader> StreamFile;
|
std::unique_ptr<BitstreamReader> StreamFile;
|
||||||
BitstreamCursor Stream;
|
BitstreamCursor Stream;
|
||||||
bool IsStreamed;
|
|
||||||
uint64_t NextUnreadBit = 0;
|
uint64_t NextUnreadBit = 0;
|
||||||
bool SeenValueSymbolTable = false;
|
bool SeenValueSymbolTable = false;
|
||||||
|
|
||||||
@ -428,15 +427,13 @@ BitcodeReader::BitcodeReader(MemoryBuffer *Buffer, LLVMContext &Context,
|
|||||||
DiagnosticHandlerFunction DiagnosticHandler)
|
DiagnosticHandlerFunction DiagnosticHandler)
|
||||||
: Context(Context),
|
: Context(Context),
|
||||||
DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
|
DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
|
||||||
Buffer(Buffer), IsStreamed(false), ValueList(Context),
|
Buffer(Buffer), ValueList(Context), MDValueList(Context) {}
|
||||||
MDValueList(Context) {}
|
|
||||||
|
|
||||||
BitcodeReader::BitcodeReader(LLVMContext &Context,
|
BitcodeReader::BitcodeReader(LLVMContext &Context,
|
||||||
DiagnosticHandlerFunction DiagnosticHandler)
|
DiagnosticHandlerFunction DiagnosticHandler)
|
||||||
: Context(Context),
|
: Context(Context),
|
||||||
DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
|
DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
|
||||||
Buffer(nullptr), IsStreamed(true), ValueList(Context),
|
Buffer(nullptr), ValueList(Context), MDValueList(Context) {}
|
||||||
MDValueList(Context) {}
|
|
||||||
|
|
||||||
std::error_code BitcodeReader::materializeForwardReferencedFunctions() {
|
std::error_code BitcodeReader::materializeForwardReferencedFunctions() {
|
||||||
if (WillMaterializeAllForwardRefs)
|
if (WillMaterializeAllForwardRefs)
|
||||||
@ -2789,13 +2786,11 @@ std::error_code BitcodeReader::parseModule(bool Resume,
|
|||||||
|
|
||||||
if (std::error_code EC = rememberAndSkipFunctionBody())
|
if (std::error_code EC = rememberAndSkipFunctionBody())
|
||||||
return EC;
|
return EC;
|
||||||
// For streaming bitcode, suspend parsing when we reach the function
|
// Suspend parsing when we reach the function bodies. Subsequent
|
||||||
// bodies. Subsequent materialization calls will resume it when
|
// materialization calls will resume it when necessary. If the bitcode
|
||||||
// necessary. For streaming, the function bodies must be at the end of
|
// file is old, the symbol table will be at the end instead and will not
|
||||||
// the bitcode. If the bitcode file is old, the symbol table will be
|
// have been seen yet. In this case, just finish the parse now.
|
||||||
// at the end instead and will not have been seen yet. In this case,
|
if (SeenValueSymbolTable) {
|
||||||
// just finish the parse now.
|
|
||||||
if (IsStreamed && SeenValueSymbolTable) {
|
|
||||||
NextUnreadBit = Stream.GetCurrentBitNo();
|
NextUnreadBit = Stream.GetCurrentBitNo();
|
||||||
return std::error_code();
|
return std::error_code();
|
||||||
}
|
}
|
||||||
@ -3049,7 +3044,6 @@ std::error_code BitcodeReader::parseModule(bool Resume,
|
|||||||
if (!isProto) {
|
if (!isProto) {
|
||||||
Func->setIsMaterializable(true);
|
Func->setIsMaterializable(true);
|
||||||
FunctionsWithBodies.push_back(Func);
|
FunctionsWithBodies.push_back(Func);
|
||||||
if (IsStreamed)
|
|
||||||
DeferredFunctionInfo[Func] = 0;
|
DeferredFunctionInfo[Func] = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4434,7 +4428,7 @@ std::error_code BitcodeReader::materialize(GlobalValue *GV) {
|
|||||||
assert(DFII != DeferredFunctionInfo.end() && "Deferred function not found!");
|
assert(DFII != DeferredFunctionInfo.end() && "Deferred function not found!");
|
||||||
// If its position is recorded as 0, its body is somewhere in the stream
|
// If its position is recorded as 0, its body is somewhere in the stream
|
||||||
// but we haven't seen it yet.
|
// but we haven't seen it yet.
|
||||||
if (DFII->second == 0 && IsStreamed)
|
if (DFII->second == 0)
|
||||||
if (std::error_code EC = findFunctionInStream(F, DFII))
|
if (std::error_code EC = findFunctionInStream(F, DFII))
|
||||||
return EC;
|
return EC;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user