summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-23 03:55:14 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-23 03:55:14 +0000
commit004509dca1948c69808f1a4682a8f62b2987e78e (patch)
tree37c48657406af4ad74a8c78df4877d17aaa2b413
parent6e6a1f0a5bb5434ddc8e94868c8fc19990ff76f4 (diff)
downloadbcm5719-llvm-004509dca1948c69808f1a4682a8f62b2987e78e.tar.gz
bcm5719-llvm-004509dca1948c69808f1a4682a8f62b2987e78e.zip
BitcodeReader: Use getMD/getMDOrNull helpers consistently, almost NFC
The only functionality change was removing an error check from the BitcodeReader (and an assertion from DILocation::getImpl) that is already caught by Verifier::visitDILocation. The Verifier is a better place for this anyway, and being inconsistent with other subclasses of MDNode isn't serving anyone. llvm-svn: 267267
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp15
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp1
2 files changed, 5 insertions, 11 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 86945c0d5cc..9d5f2807900 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2057,7 +2057,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
if (!Ty)
return error("Invalid record");
if (Ty->isMetadataTy())
- Elts.push_back(MetadataList.getMetadataFwdRef(Record[i + 1]));
+ Elts.push_back(getMD(Record[i + 1]));
else if (!Ty->isVoidTy()) {
auto *MD =
ValueAsMetadata::get(ValueList.getValueFwdRef(Record[i + 1], Ty));
@@ -2090,7 +2090,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
SmallVector<Metadata *, 8> Elts;
Elts.reserve(Record.size());
for (unsigned ID : Record)
- Elts.push_back(ID ? MetadataList.getMetadataFwdRef(ID - 1) : nullptr);
+ Elts.push_back(getMDOrNull(ID));
MetadataList.assignValue(IsDistinct ? MDNode::getDistinct(Context, Elts)
: MDNode::get(Context, Elts),
NextMetadataNo++);
@@ -2102,11 +2102,8 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
unsigned Line = Record[1];
unsigned Column = Record[2];
- MDNode *Scope = MetadataList.getMDNodeFwdRefOrNull(Record[3]);
- if (!Scope)
- return error("Invalid record");
- Metadata *InlinedAt =
- Record[4] ? MetadataList.getMetadataFwdRef(Record[4] - 1) : nullptr;
+ Metadata *Scope = getMD(Record[3]);
+ Metadata *InlinedAt = getMDOrNull(Record[4]);
MetadataList.assignValue(
GET_OR_DISTINCT(DILocation, Record[0],
(Context, Line, Column, Scope, InlinedAt)),
@@ -2126,9 +2123,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
auto *Header = getMDString(Record[3]);
SmallVector<Metadata *, 8> DwarfOps;
for (unsigned I = 4, E = Record.size(); I != E; ++I)
- DwarfOps.push_back(Record[I]
- ? MetadataList.getMetadataFwdRef(Record[I] - 1)
- : nullptr);
+ DwarfOps.push_back(getMDOrNull(Record[I]));
MetadataList.assignValue(
GET_OR_DISTINCT(GenericDINode, Record[0],
(Context, Tag, Header, DwarfOps)),
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 3475971d348..2c9873078c4 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -45,7 +45,6 @@ DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
// Fixup column.
adjustColumn(Column);
- assert(Scope && "Expected scope");
if (Storage == Uniqued) {
if (auto *N =
getUniqued(Context.pImpl->DILocations,
OpenPOWER on IntegriCloud