summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-09-13 01:12:59 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-09-13 01:12:59 +0000
commitd4135bbc30de3d3dbd44d64d718fb2169f41bae0 (patch)
tree0b96e34c50822aed89a2272d9e9f3688bc3a0e46 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentefc066758309683482edd289d82ec7670d38931f (diff)
downloadbcm5719-llvm-d4135bbc30de3d3dbd44d64d718fb2169f41bae0.tar.gz
bcm5719-llvm-d4135bbc30de3d3dbd44d64d718fb2169f41bae0.zip
DebugInfo: New metadata representation for global variables.
This patch reverses the edge from DIGlobalVariable to GlobalVariable. This will allow us to more easily preserve debug info metadata when manipulating global variables. Fixes PR30362. A program for upgrading test cases is attached to that bug. Differential Revision: http://reviews.llvm.org/D20147 llvm-svn: 281284
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index db82766aa6c..2504ce78cc6 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2679,14 +2679,35 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
return error("Invalid record");
IsDistinct = Record[0];
- MetadataList.assignValue(
- GET_OR_DISTINCT(DIGlobalVariable,
- (Context, getMDOrNull(Record[1]),
- getMDString(Record[2]), getMDString(Record[3]),
- getMDOrNull(Record[4]), Record[5],
- getDITypeRefOrNull(Record[6]), Record[7], Record[8],
- getMDOrNull(Record[9]), getMDOrNull(Record[10]))),
- NextMetadataNo++);
+
+ // Upgrade old metadata, which stored a global variable reference or a
+ // ConstantInt here.
+ Metadata *Expr = getMDOrNull(Record[9]);
+ GlobalVariable *Attach = nullptr;
+ if (auto *CMD = dyn_cast_or_null<ConstantAsMetadata>(Expr)) {
+ if (auto *GV = dyn_cast<GlobalVariable>(CMD->getValue())) {
+ Attach = GV;
+ Expr = nullptr;
+ } else if (auto *CI = dyn_cast<ConstantInt>(CMD->getValue())) {
+ Expr = DIExpression::get(Context,
+ {dwarf::DW_OP_constu, CI->getZExtValue(),
+ dwarf::DW_OP_stack_value});
+ } else {
+ Expr = nullptr;
+ }
+ }
+
+ DIGlobalVariable *DGV = GET_OR_DISTINCT(
+ DIGlobalVariable,
+ (Context, getMDOrNull(Record[1]), getMDString(Record[2]),
+ getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
+ getDITypeRefOrNull(Record[6]), Record[7], Record[8], Expr,
+ getMDOrNull(Record[10])));
+ MetadataList.assignValue(DGV, NextMetadataNo++);
+
+ if (Attach)
+ Attach->addDebugInfo(DGV);
+
break;
}
case bitc::METADATA_LOCAL_VAR: {
OpenPOWER on IntegriCloud