Fix bitcode auto-upgrade when using bitcode lazy loading

The auto-upgrade path could be called before the VST (global
names) was fully parsed, and thus intrinsic names were not
available and the autoupgrade logic could not operate.

Fix link failures with ThinLTO.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278610 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mehdi Amini
2016-08-13 23:31:53 +00:00
parent 804c815e77
commit c5432bdac5
3 changed files with 32 additions and 9 deletions

View File

@@ -3634,15 +3634,6 @@ std::error_code BitcodeReader::parseModule(uint64_t ResumeBit,
return EC;
break;
case bitc::FUNCTION_BLOCK_ID:
// If this is the first function body we've seen, reverse the
// FunctionsWithBodies list.
if (!SeenFirstFunctionBody) {
std::reverse(FunctionsWithBodies.begin(), FunctionsWithBodies.end());
if (std::error_code EC = globalCleanup())
return EC;
SeenFirstFunctionBody = true;
}
if (VSTOffset > 0) {
// If we have a VST forward declaration record, make sure we
// parse the VST now if we haven't already. It is needed to
@@ -3669,6 +3660,15 @@ std::error_code BitcodeReader::parseModule(uint64_t ResumeBit,
}
}
// If this is the first function body we've seen, reverse the
// FunctionsWithBodies list.
if (!SeenFirstFunctionBody) {
std::reverse(FunctionsWithBodies.begin(), FunctionsWithBodies.end());
if (std::error_code EC = globalCleanup())
return EC;
SeenFirstFunctionBody = true;
}
// Support older bitcode files that did not have the function
// index in the VST, nor a VST forward declaration record, as
// well as anonymous functions that do not have VST entries.