From: Vedant Kumar Date: Thu, 20 Sep 2018 18:59:33 +0000 (+0000) Subject: [Bitcode] Address backwards compat bug in r342631 X-Git-Tag: llvmorg-8.0.0-rc1~8303 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=386ad01c7b6d83beb95267116af295471e36d426;p=platform%2Fupstream%2Fllvm.git [Bitcode] Address backwards compat bug in r342631 r342631 expanded bitc::METADATA_LOCATION by one element. The bitcode metadata loader was changed in a backwards-incompatible way, leading to crashes when disassembling old bitcode: assertion: empty() && "PlaceholderQueue hasn't been flushed before being destroyed" Assertion failed: (empty() && "PlaceholderQueue hasn't been flushed before being destroyed") This commit teaches the metadata loader to assume that the newly-added IsImplicitCode bit is 'false' when not present in old bitcode. I've added a bitcode compat regression test. rdar://44645820 llvm-svn: 342678 --- diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index 1af17f4..3fe7d22 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -1139,7 +1139,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( break; } case bitc::METADATA_LOCATION: { - if (Record.size() != 6) + if (Record.size() != 5 && Record.size() != 6) return error("Invalid record"); IsDistinct = Record[0]; @@ -1147,7 +1147,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( unsigned Column = Record[2]; Metadata *Scope = getMD(Record[3]); Metadata *InlinedAt = getMDOrNull(Record[4]); - bool ImplicitCode = Record[5]; + bool ImplicitCode = Record.size() == 6 && Record[5]; MetadataList.assignValue( GET_OR_DISTINCT(DILocation, (Context, Line, Column, Scope, InlinedAt, ImplicitCode)), diff --git a/llvm/test/Bitcode/Inputs/apple-clang-700-O3-g-1.bc b/llvm/test/Bitcode/Inputs/apple-clang-700-O3-g-1.bc new file mode 100644 index 0000000..01f221d Binary files /dev/null and b/llvm/test/Bitcode/Inputs/apple-clang-700-O3-g-1.bc differ diff --git a/llvm/test/Bitcode/apple-clang-700-compat.test b/llvm/test/Bitcode/apple-clang-700-compat.test new file mode 100644 index 0000000..c7ab2f4 --- /dev/null +++ b/llvm/test/Bitcode/apple-clang-700-compat.test @@ -0,0 +1,8 @@ +; AppleClang-700 uses a debug info version that isn't recognized by llvm.org +; compilers. However, it does produce valid bitcode which should parse without +; crashing the metadata loader. + +RUN: llvm-dis < %S/Inputs/apple-clang-700-O3-g-1.bc 2>&1 \ +RUN: | FileCheck %s -check-prefix INVALID-VERSION + +INVALID-VERSION: warning: ignoring debug info with an invalid version (700000003)