aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-24 06:52:01 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-24 06:52:01 +0000
commit5892c6b94b882d10952204a67e7e44ea9c387ca5 (patch)
tree6c305e34be7c011bc08783289a0619485e32d391 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentdbc981f71fa2f000c4c58b8be8e9aae9eeee0d9f (diff)
downloadllvm-5892c6b94b882d10952204a67e7e44ea9c387ca5.zip
llvm-5892c6b94b882d10952204a67e7e44ea9c387ca5.tar.gz
llvm-5892c6b94b882d10952204a67e7e44ea9c387ca5.tar.bz2
BitcodeReader: Fix some holes in upgrade from r267296
Add tests for some missing cases to bitcode upgrade in r267296. - DICompositeType with an 'elements:' field, which will cause it to be involved in a cycle after the upgrade. - A DIDerivedType that references a class in 'extraData:'. I updated test/Bitcode/dityperefs-3.8.ll with the missing cases and regenerated test/Bitcode/dityperefs-3.8.ll.bc. llvm-svn: 267332
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index b8db3e8f..7dbf4e6 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1158,6 +1158,8 @@ void BitcodeReaderMetadataList::tryToResolveCycles() {
// Still forward references... can't resolve cycles.
return;
+ bool DidReplaceTypeRefs = false;
+
// Give up on finding a full definition for any forward decls that remain.
for (const auto &Ref : OldTypeRefs.FwdDecls)
OldTypeRefs.Final.insert(Ref);
@@ -1165,19 +1167,31 @@ void BitcodeReaderMetadataList::tryToResolveCycles() {
// Upgrade from old type ref arrays. In strange cases, this could add to
// OldTypeRefs.Unknown.
- for (const auto &Array : OldTypeRefs.Arrays)
+ for (const auto &Array : OldTypeRefs.Arrays) {
+ DidReplaceTypeRefs = true;
Array.second->replaceAllUsesWith(resolveTypeRefArray(Array.first.get()));
+ }
+ OldTypeRefs.Arrays.clear();
// Replace old string-based type refs with the resolved node, if possible.
// If we haven't seen the node, leave it to the verifier to complain about
// the invalid string reference.
- for (const auto &Ref : OldTypeRefs.Unknown)
+ for (const auto &Ref : OldTypeRefs.Unknown) {
+ DidReplaceTypeRefs = true;
if (DICompositeType *CT = OldTypeRefs.Final.lookup(Ref.first))
Ref.second->replaceAllUsesWith(CT);
else
Ref.second->replaceAllUsesWith(Ref.first);
+ }
OldTypeRefs.Unknown.clear();
+ // Make sure all the upgraded types are resolved.
+ if (DidReplaceTypeRefs) {
+ AnyFwdRefs = true;
+ MinFwdRef = 0;
+ MaxFwdRef = MetadataPtrs.size() - 1;
+ }
+
if (!AnyFwdRefs)
// Nothing to do.
return;
@@ -2346,12 +2360,12 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
IsDistinct = Record[0];
MetadataList.assignValue(
- GET_OR_DISTINCT(DIDerivedType,
- (Context, Record[1], getMDString(Record[2]),
- getMDOrNull(Record[3]), Record[4],
- getDITypeRefOrNull(Record[5]),
- getDITypeRefOrNull(Record[6]), Record[7], Record[8],
- Record[9], Record[10], getMDOrNull(Record[11]))),
+ GET_OR_DISTINCT(
+ DIDerivedType,
+ (Context, Record[1], getMDString(Record[2]),
+ getMDOrNull(Record[3]), Record[4], getDITypeRefOrNull(Record[5]),
+ getDITypeRefOrNull(Record[6]), Record[7], Record[8], Record[9],
+ Record[10], getDITypeRefOrNull(Record[11]))),
NextMetadataNo++);
break;
}