summaryrefslogtreecommitdiff
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-08-30 18:06:51 +0000
committerAdrian Prantl <aprantl@apple.com>2017-08-30 18:06:51 +0000
commit69e607f200faf0384a737bd8db69f29e51e1b378 (patch)
tree2623b1ea8144906eaa3c8707e47d05fdf46b2783 /lib/Bitcode
parentec6b6f4e7ad864820eb26875edf94f28c466e053 (diff)
Canonicalize the representation of empty an expression in DIGlobalVariableExpression
This change simplifies code that has to deal with DIGlobalVariableExpression and mirrors how we treat DIExpressions in debug info intrinsics. Before this change there were two ways of representing empty expressions on globals, a nullptr and an empty !DIExpression(). If someone needs to upgrade out-of-tree testcases: perl -pi -e 's/(!DIGlobalVariableExpression\(var: ![0-9]*)\)/\1, expr: !DIExpression())/g' <MYTEST.ll> will catch 95%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312144 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/MetadataLoader.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Bitcode/Reader/MetadataLoader.cpp b/lib/Bitcode/Reader/MetadataLoader.cpp
index 10fbcdea784..3aadee457bf 100644
--- a/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -497,8 +497,8 @@ class MetadataLoader::MetadataLoaderImpl {
for (unsigned I = 0; I < GVs->getNumOperands(); I++)
if (auto *GV =
dyn_cast_or_null<DIGlobalVariable>(GVs->getOperand(I))) {
- auto *DGVE =
- DIGlobalVariableExpression::getDistinct(Context, GV, nullptr);
+ auto *DGVE = DIGlobalVariableExpression::getDistinct(
+ Context, GV, DIExpression::get(Context, {}));
GVs->replaceOperandWith(I, DGVE);
}
}
@@ -510,8 +510,8 @@ class MetadataLoader::MetadataLoaderImpl {
GV.eraseMetadata(LLVMContext::MD_dbg);
for (auto *MD : MDs)
if (auto *DGV = dyn_cast_or_null<DIGlobalVariable>(MD)) {
- auto *DGVE =
- DIGlobalVariableExpression::getDistinct(Context, DGV, nullptr);
+ auto *DGVE = DIGlobalVariableExpression::getDistinct(
+ Context, DGV, DIExpression::get(Context, {}));
GV.addMetadata(LLVMContext::MD_dbg, *DGVE);
} else
GV.addMetadata(LLVMContext::MD_dbg, *MD);
@@ -1585,7 +1585,8 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
DIGlobalVariableExpression *DGVE = nullptr;
if (Attach || Expr)
- DGVE = DIGlobalVariableExpression::getDistinct(Context, DGV, Expr);
+ DGVE = DIGlobalVariableExpression::getDistinct(
+ Context, DGV, Expr ? Expr : DIExpression::get(Context, {}));
if (Attach)
Attach->addDebugInfo(DGVE);
@@ -1648,10 +1649,13 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
return error("Invalid record");
IsDistinct = Record[0];
- MetadataList.assignValue(GET_OR_DISTINCT(DIGlobalVariableExpression,
- (Context, getMDOrNull(Record[1]),
- getMDOrNull(Record[2]))),
- NextMetadataNo);
+ Metadata *Expr = getMDOrNull(Record[2]);
+ if (!Expr)
+ Expr = DIExpression::get(Context, {});
+ MetadataList.assignValue(
+ GET_OR_DISTINCT(DIGlobalVariableExpression,
+ (Context, getMDOrNull(Record[1]), Expr)),
+ NextMetadataNo);
NextMetadataNo++;
break;
}