[llvm] r342678 - [Bitcode] Address backwards compat bug in r342631
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 20 11:59:33 PDT 2018
Author: vedantk
Date: Thu Sep 20 11:59:33 2018
New Revision: 342678
URL: http://llvm.org/viewvc/llvm-project?rev=342678&view=rev
Log:
[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
Added:
llvm/trunk/test/Bitcode/Inputs/apple-clang-700-O3-g-1.bc (with props)
llvm/trunk/test/Bitcode/apple-clang-700-compat.test
Modified:
llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
Modified: llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp?rev=342678&r1=342677&r2=342678&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp Thu Sep 20 11:59:33 2018
@@ -1139,7 +1139,7 @@ Error MetadataLoader::MetadataLoaderImpl
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
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)),
Added: llvm/trunk/test/Bitcode/Inputs/apple-clang-700-O3-g-1.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/Inputs/apple-clang-700-O3-g-1.bc?rev=342678&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/Bitcode/Inputs/apple-clang-700-O3-g-1.bc
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: llvm/trunk/test/Bitcode/apple-clang-700-compat.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/apple-clang-700-compat.test?rev=342678&view=auto
==============================================================================
--- llvm/trunk/test/Bitcode/apple-clang-700-compat.test (added)
+++ llvm/trunk/test/Bitcode/apple-clang-700-compat.test Thu Sep 20 11:59:33 2018
@@ -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)
More information about the llvm-commits
mailing list