diff options
| author | Adrian Prantl <aprantl@apple.com> | 2017-08-30 18:06:51 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2017-08-30 18:06:51 +0000 |
| commit | 05782218abd549e0c1bc77032fa9b55526371cfd (patch) | |
| tree | 1cd1e0e5ace565ad80e6e9053bb7d858a38362b5 /llvm/lib | |
| parent | 1a4cbbe49fcaebe63246c784983556528bcb27d8 (diff) | |
| download | bcm5719-llvm-05782218abd549e0c1bc77032fa9b55526371cfd.tar.gz bcm5719-llvm-05782218abd549e0c1bc77032fa9b55526371cfd.zip | |
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%.
llvm-svn: 312144
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 22 | ||||
| -rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 2 |
3 files changed, 16 insertions, 10 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index a5f4dd73d30..a1bb8602192 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -4383,7 +4383,7 @@ bool LLParser::ParseDIGlobalVariableExpression(MDNode *&Result, bool IsDistinct) { #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ REQUIRED(var, MDField, ); \ - OPTIONAL(expr, MDField, ); + REQUIRED(expr, MDField, ); PARSE_MD_FIELDS(); #undef VISIT_MD_FIELDS diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index 10fbcdea784..3aadee457bf 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/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; } diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 5d4181a2c51..1bd9d557b8f 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -595,6 +595,8 @@ DIGlobalVariableExpression *DIBuilder::createGlobalVariableExpression( VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F, LineNumber, Ty, isLocalToUnit, true, cast_or_null<DIDerivedType>(Decl), AlignInBits); + if (!Expr) + Expr = createExpression(); auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr); AllGVs.push_back(N); return N; |

