diff options
| author | Adrian Prantl <aprantl@apple.com> | 2017-08-19 01:15:06 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2017-08-19 01:15:06 +0000 |
| commit | 2116dd360a3f118691c0383f1eef08ec8f4ae6d5 (patch) | |
| tree | 2aa6eb04b442a0f02d29ca59dfea7e1d08ee7d81 | |
| parent | 0da12c841adee9718cd75e4ff4ddc37db89f6832 (diff) | |
| download | bcm5719-llvm-2116dd360a3f118691c0383f1eef08ec8f4ae6d5.tar.gz bcm5719-llvm-2116dd360a3f118691c0383f1eef08ec8f4ae6d5.zip | |
Filter out non-constant DIGlobalVariableExpressions reachable via the CU
They won't affect the DWARF output, but they will mess with the
sorting of the fragments. This fixes the crash reported in PR34159.
https://bugs.llvm.org/show_bug.cgi?id=34159
llvm-svn: 311217
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 11 | ||||
| -rw-r--r-- | llvm/test/DebugInfo/X86/split-global.ll | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 21f632a9194..d724c9325e1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -592,8 +592,15 @@ void DwarfDebug::beginModule() { DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(CUNode); // Global Variables. - for (auto *GVE : CUNode->getGlobalVariables()) - GVMap[GVE->getVariable()].push_back({nullptr, GVE->getExpression()}); + for (auto *GVE : CUNode->getGlobalVariables()) { + // Don't bother adding DIGlobalVariableExpressions listed in the CU if we + // already know about the variable and it isn't adding a constant + // expression. + auto &GVMapEntry = GVMap[GVE->getVariable()]; + auto *Expr = GVE->getExpression(); + if (!GVMapEntry.size() || (Expr && Expr->isConstant())) + GVMapEntry.push_back({nullptr, Expr}); + } DenseSet<DIGlobalVariable *> Processed; for (auto *GVE : CUNode->getGlobalVariables()) { DIGlobalVariable *GV = GVE->getVariable(); diff --git a/llvm/test/DebugInfo/X86/split-global.ll b/llvm/test/DebugInfo/X86/split-global.ll index 3cdecdafc8d..6a80db5dd7a 100644 --- a/llvm/test/DebugInfo/X86/split-global.ll +++ b/llvm/test/DebugInfo/X86/split-global.ll @@ -39,7 +39,7 @@ target triple = "x86_64-apple-macosx10.12.0" !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4) !2 = !DIFile(filename: "g.c", directory: "/") !3 = !{} -!4 = !{!12, !13, !14, !15, !17, !18} +!4 = !{!12, !13, !14, !15, !17, !18, !20} !5 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !2, line: 1, size: 64, elements: !6) !6 = !{!7, !9} !7 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !5, file: !2, line: 1, baseType: !8, size: 32) @@ -58,3 +58,4 @@ target triple = "x86_64-apple-macosx10.12.0" !18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression(DW_OP_constu, 2, DW_OP_stack_value, DW_OP_LLVM_fragment, 32, 32)) !19 = distinct !DIGlobalVariable(name: "full_const", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true) +!20 = !DIGlobalVariableExpression(var: !0) |

