<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 20, 2016 at 4:24 PM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Based on the discussion about DISubprogram deduplication for inline functions in (all flavors of) LTO - could we make this unit link null for non-external (well, specifically globals that can be duplicated - linkonce_odr and the like) & just emit those into whichever CU references them first?<br class="gmail_msg"><br class="gmail_msg">This would avoid redundant descriptions (where all but one lacks any location description, etc) of deduplicable globals. Though perhaps it's a non-issue for globals, since they aren't inlined - but they could be reduced to a constant which is sort of the same.<br class="gmail_msg"><br class="gmail_msg">I can explain/provide examples if I'm being vague/hand-wavy.</div></blockquote><div><br></div><div>Was there an answer/resolution to this ^ I couldn't quite see it in the thread or changes to on phab. (the comment at the top still says that definitions have a CU link)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Tue, Dec 20, 2016 at 4:16 PM Adrian Prantl via Phabricator <<a href="mailto:reviews@reviews.llvm.org" class="gmail_msg" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">aprantl created this revision.<br class="gmail_msg">
aprantl added reviewers: dexonsmith, dblaikie.<br class="gmail_msg">
aprantl added a subscriber: llvm-commits.<br class="gmail_msg">
Herald added subscribers: nemanjai, mehdi_amini, sanjoy, jfb, jholewinski.<br class="gmail_msg">
<br class="gmail_msg">
This has been suggested as an incremental follow-up to <a href="https://reviews.llvm.org/D26769" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D26769</a>.<br class="gmail_msg">
<br class="gmail_msg">
Adding a unit field to DIGlobalVariable makes the design consistent with the design of DISubprogram<br class="gmail_msg">
(DISubprogram **definitions** that are attached to Functions also have a unit field).<br class="gmail_msg">
It also allows us to more efficiently process global variables in the DWARF backend.<br class="gmail_msg">
<br class="gmail_msg">
After this patch, global variables occur in three forms in the debug info metadata:<br class="gmail_msg">
<br class="gmail_msg">
1. **Variable definitions** are reachable via a !dbg attachment on a global that points to a DIGlobalVariableExpression which points to a distinct DIGlobalVariable (and an optional DIExpression) with a unit field pointing to the variable's DICompileUnit.<br class="gmail_msg">
<br class="gmail_msg">
2. **Constant definitions** are reachable via the DICompileUnit's list of globals which points to a DIGlobalVariableExpression with a DIGlobalVariable without a unit field and a DIExpression describing a constant value.<br class="gmail_msg">
<br class="gmail_msg">
3. **Declarations** are DIGlobalVariables without a unit field that are only reachable via a DIImportedEntity and have isDefinition set to false.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D28005" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D28005</a><br class="gmail_msg">
<br class="gmail_msg">
Files:<br class="gmail_msg">
  docs/SourceLevelDebugging.rst<br class="gmail_msg">
  include/llvm/IR/DebugInfoMetadata.h<br class="gmail_msg">
  lib/AsmParser/LLParser.cpp<br class="gmail_msg">
  lib/Bitcode/Reader/MetadataLoader.cpp<br class="gmail_msg">
  lib/Bitcode/Writer/BitcodeWriter.cpp<br class="gmail_msg">
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br class="gmail_msg">
  lib/IR/AsmWriter.cpp<br class="gmail_msg">
  lib/IR/DIBuilder.cpp<br class="gmail_msg">
  lib/IR/DebugInfoMetadata.cpp<br class="gmail_msg">
  lib/IR/LLVMContextImpl.h<br class="gmail_msg">
  lib/IR/Verifier.cpp<br class="gmail_msg">
  test/Bitcode/diglobalvariable-3.8.ll<br class="gmail_msg">
  test/CodeGen/AArch64/arm64-2011-03-17-AsmPrinterCrash.ll<br class="gmail_msg">
  test/CodeGen/ARM/2010-06-25-Thumb2ITInvalidIterator.ll<br class="gmail_msg">
  test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll<br class="gmail_msg">
  test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll<br class="gmail_msg">
  test/CodeGen/ARM/coalesce-dbgvalue.ll<br class="gmail_msg">
  test/CodeGen/BPF/dwarfdump.ll<br class="gmail_msg">
  test/CodeGen/NVPTX/generic-to-nvvm-ir.ll<br class="gmail_msg">
  test/CodeGen/PowerPC/pr17168.ll<br class="gmail_msg">
  test/CodeGen/PowerPC/pr24546.ll<br class="gmail_msg">
  test/CodeGen/WebAssembly/dbgvalue.ll<br class="gmail_msg">
  test/CodeGen/X86/2010-05-26-DotDebugLoc.ll<br class="gmail_msg">
  test/CodeGen/X86/fp128-g.ll<br class="gmail_msg">
  test/CodeGen/X86/fpstack-debuginstr-kill.ll<br class="gmail_msg">
  test/CodeGen/X86/misched-code-difference-with-debug.ll<br class="gmail_msg">
  test/CodeGen/X86/null-streamer.ll<br class="gmail_msg">
  test/DebugInfo/AArch64/big-endian.ll<br class="gmail_msg">
  test/DebugInfo/AArch64/bitfields.ll<br class="gmail_msg">
  test/DebugInfo/AArch64/frameindices.ll<br class="gmail_msg">
  test/DebugInfo/ARM/big-endian-bitfield.ll<br class="gmail_msg">
  test/DebugInfo/ARM/bitfield.ll<br class="gmail_msg">
  test/DebugInfo/ARM/multiple-constant-uses-drops-dbgloc.ll<br class="gmail_msg">
  test/DebugInfo/ARM/tls.ll<br class="gmail_msg">
  test/DebugInfo/COFF/anonymous-struct.ll<br class="gmail_msg">
  test/DebugInfo/COFF/big-type.ll<br class="gmail_msg">
  test/DebugInfo/COFF/bitfields.ll<br class="gmail_msg">
  test/DebugInfo/COFF/enum.ll<br class="gmail_msg">
  test/DebugInfo/COFF/global-dllimport.ll<br class="gmail_msg">
  test/DebugInfo/COFF/globals-discarded.ll<br class="gmail_msg">
  test/DebugInfo/COFF/globals.ll<br class="gmail_msg">
  test/DebugInfo/COFF/inheritance.ll<br class="gmail_msg">
  test/DebugInfo/COFF/inlining-files.ll<br class="gmail_msg">
  test/DebugInfo/COFF/inlining-header.ll<br class="gmail_msg">
  test/DebugInfo/COFF/inlining-levels.ll<br class="gmail_msg">
  test/DebugInfo/COFF/int8-char-type.ll<br class="gmail_msg">
  test/DebugInfo/COFF/long-type-name.ll<br class="gmail_msg">
  test/DebugInfo/COFF/register-variables.ll<br class="gmail_msg">
  test/DebugInfo/COFF/scopes.ll<br class="gmail_msg">
  test/DebugInfo/COFF/types-array-advanced.ll<br class="gmail_msg">
  test/DebugInfo/COFF/types-nested-class.ll<br class="gmail_msg">
  test/DebugInfo/COFF/types-ptr-to-member.ll<br class="gmail_msg">
  test/DebugInfo/COFF/udts.ll<br class="gmail_msg">
  test/DebugInfo/COFF/virtual-method-kinds.ll<br class="gmail_msg">
  test/DebugInfo/COFF/vtable-optzn-array.ll<br class="gmail_msg">
  test/DebugInfo/Generic/2009-11-05-DeadGlobalVariable.ll<br class="gmail_msg">
  test/DebugInfo/Generic/2009-11-06-NamelessGlobalVariable.ll<br class="gmail_msg">
  test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll<br class="gmail_msg">
  test/DebugInfo/Generic/accel-table-hash-collisions.ll<br class="gmail_msg">
  test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll<br class="gmail_msg">
  test/DebugInfo/Generic/cross-cu-linkonce.ll<br class="gmail_msg">
  test/DebugInfo/Generic/dbg-at-specficiation.ll<br class="gmail_msg">
  test/DebugInfo/Generic/debuginfofinder-forward-declaration.ll<br class="gmail_msg">
  test/DebugInfo/Generic/dwarf-public-names.ll<br class="gmail_msg">
  test/DebugInfo/Generic/enum.ll<br class="gmail_msg">
  test/DebugInfo/Generic/global.ll<br class="gmail_msg">
  test/DebugInfo/Generic/gvn.ll<br class="gmail_msg">
  test/DebugInfo/Generic/member-pointers.ll<br class="gmail_msg">
  test/DebugInfo/Generic/namespace.ll<br class="gmail_msg">
  test/DebugInfo/Generic/recursive_inlining.ll<br class="gmail_msg">
  test/DebugInfo/Generic/template-recursive-void.ll<br class="gmail_msg">
  test/DebugInfo/Generic/tu-member-pointer.ll<br class="gmail_msg">
  test/DebugInfo/Generic/typedef.ll<br class="gmail_msg">
  test/DebugInfo/MIR/X86/live-debug-values.mir<br class="gmail_msg">
  test/DebugInfo/MIR/X86/mlicm-hoist.mir<br class="gmail_msg">
  test/DebugInfo/Mips/InlinedFnLocalVar.ll<br class="gmail_msg">
  test/DebugInfo/PowerPC/tls-fission.ll<br class="gmail_msg">
  test/DebugInfo/PowerPC/tls.ll<br class="gmail_msg">
  test/DebugInfo/WebAssembly/dbg-declare.ll<br class="gmail_msg">
  test/DebugInfo/X86/2011-09-26-GlobalVarContext.ll<br class="gmail_msg">
  test/DebugInfo/X86/DIModuleContext.ll<br class="gmail_msg">
  test/DebugInfo/X86/DW_AT_calling-convention.ll<br class="gmail_msg">
  test/DebugInfo/X86/DW_AT_specification.ll<br class="gmail_msg">
  test/DebugInfo/X86/DW_TAG_friend.ll<br class="gmail_msg">
  test/DebugInfo/X86/InlinedFnLocalVar.ll<br class="gmail_msg">
  test/DebugInfo/X86/PR26148.ll<br class="gmail_msg">
  test/DebugInfo/X86/align_c11.ll<br class="gmail_msg">
  test/DebugInfo/X86/align_cpp11.ll<br class="gmail_msg">
  test/DebugInfo/X86/align_objc.ll<br class="gmail_msg">
  test/DebugInfo/X86/arange-and-stub.ll<br class="gmail_msg">
  test/DebugInfo/X86/arange.ll<br class="gmail_msg">
  test/DebugInfo/X86/atomic-c11-dwarf-4.ll<br class="gmail_msg">
  test/DebugInfo/X86/atomic-c11-dwarf-5.ll<br class="gmail_msg">
  test/DebugInfo/X86/bitfields-dwarf4.ll<br class="gmail_msg">
  test/DebugInfo/X86/bitfields.ll<br class="gmail_msg">
  test/DebugInfo/X86/c-type-units.ll<br class="gmail_msg">
  test/DebugInfo/X86/concrete_out_of_line.ll<br class="gmail_msg">
  test/DebugInfo/X86/cu-ranges-odr.ll<br class="gmail_msg">
  test/DebugInfo/X86/data_member_location.ll<br class="gmail_msg">
  test/DebugInfo/X86/dbg-subrange.ll<br class="gmail_msg">
  test/DebugInfo/X86/dbg-value-inlined-parameter.ll<br class="gmail_msg">
  test/DebugInfo/X86/dbg-value-regmask-clobber.ll<br class="gmail_msg">
  test/DebugInfo/X86/debug-info-access.ll<br class="gmail_msg">
  test/DebugInfo/X86/debug-info-packed-struct.ll<br class="gmail_msg">
  test/DebugInfo/X86/debug-info-static-member.ll<br class="gmail_msg">
  test/DebugInfo/X86/debug-loc-frame.ll<br class="gmail_msg">
  test/DebugInfo/X86/debugger-tune.ll<br class="gmail_msg">
  test/DebugInfo/X86/decl-derived-member.ll<br class="gmail_msg">
  test/DebugInfo/X86/dllimport.ll<br class="gmail_msg">
  test/DebugInfo/X86/dwarf-aranges-no-dwarf-labels.ll<br class="gmail_msg">
  test/DebugInfo/X86/dwarf-aranges.ll<br class="gmail_msg">
  test/DebugInfo/X86/dwarf-linkage-names.ll<br class="gmail_msg">
  test/DebugInfo/X86/dwarf-public-names.ll<br class="gmail_msg">
  test/DebugInfo/X86/empty-array.ll<br class="gmail_msg">
  test/DebugInfo/X86/enum-class.ll<br class="gmail_msg">
  test/DebugInfo/X86/enum-fwd-decl.ll<br class="gmail_msg">
  test/DebugInfo/X86/externaltyperef.ll<br class="gmail_msg">
  test/DebugInfo/X86/fission-cu.ll<br class="gmail_msg">
  test/DebugInfo/X86/generate-odr-hash.ll<br class="gmail_msg">
  test/DebugInfo/X86/gnu-public-names.ll<br class="gmail_msg">
  test/DebugInfo/X86/inline-member-function.ll<br class="gmail_msg">
  test/DebugInfo/X86/inline-namespace.ll<br class="gmail_msg">
  test/DebugInfo/X86/inlined-indirect-value.ll<br class="gmail_msg">
  test/DebugInfo/X86/isel-cse-line.ll<br class="gmail_msg">
  test/DebugInfo/X86/linkage-name.ll<br class="gmail_msg">
  test/DebugInfo/X86/live-debug-values.ll<br class="gmail_msg">
  test/DebugInfo/X86/memberfnptr.ll<br class="gmail_msg">
  test/DebugInfo/X86/misched-dbg-value.ll<br class="gmail_msg">
  test/DebugInfo/X86/multiple-aranges.ll<br class="gmail_msg">
  test/DebugInfo/X86/nondefault-subrange-array.ll<br class="gmail_msg">
  test/DebugInfo/X86/objc-fwd-decl.ll<br class="gmail_msg">
  test/DebugInfo/X86/pointer-type-size.ll<br class="gmail_msg">
  test/DebugInfo/X86/ref_addr_relocation.ll<br class="gmail_msg">
  test/DebugInfo/X86/split-global.ll<br class="gmail_msg">
  test/DebugInfo/X86/stack-value-dwarf4.ll<br class="gmail_msg">
  test/DebugInfo/X86/static_member_array.ll<br class="gmail_msg">
  test/DebugInfo/X86/stringpool.ll<br class="gmail_msg">
  test/DebugInfo/X86/struct-loc.ll<br class="gmail_msg">
  test/DebugInfo/X86/template.ll<br class="gmail_msg">
  test/DebugInfo/X86/tls.ll<br class="gmail_msg">
  test/DebugInfo/X86/type_units_with_addresses.ll<br class="gmail_msg">
  test/DebugInfo/X86/union-template.ll<br class="gmail_msg">
  test/DebugInfo/X86/vector.ll<br class="gmail_msg">
  test/Instrumentation/AddressSanitizer/debug-info-global-var.ll<br class="gmail_msg">
  test/LTO/X86/Inputs/type-mapping-src.ll<br class="gmail_msg">
  test/LTO/X86/type-mapping-bug.ll<br class="gmail_msg">
  test/Linker/2011-08-04-Metadata.ll<br class="gmail_msg">
  test/Linker/2011-08-04-Metadata2.ll<br class="gmail_msg">
  test/Linker/debug-info-global-var.ll<br class="gmail_msg">
  test/Linker/odr.ll<br class="gmail_msg">
  test/Linker/only-needed-debug-metadata.ll<br class="gmail_msg">
  test/ThinLTO/X86/Inputs/crash_debuginfo.ll<br class="gmail_msg">
  test/ThinLTO/X86/crash_debuginfo.ll<br class="gmail_msg">
  test/ThinLTO/X86/debuginfo-cu-import.ll<br class="gmail_msg">
  test/Transforms/GCOVProfiling/return-block.ll<br class="gmail_msg">
  test/Transforms/GlobalMerge/debug-info.ll<br class="gmail_msg">
  test/Transforms/GlobalOpt/2009-03-05-dbg.ll<br class="gmail_msg">
  test/Transforms/Inline/alloca-dbgdeclare.ll<br class="gmail_msg">
  test/Transforms/LoopVectorize/dbg.value.ll<br class="gmail_msg">
  test/Transforms/SampleProfile/cov-zero-samples.ll<br class="gmail_msg">
  test/Transforms/SimplifyCFG/PR27615-simplify-cond-br.ll<br class="gmail_msg">
  test/Transforms/StripSymbols/2010-06-30-StripDebug.ll<br class="gmail_msg">
  test/Transforms/StripSymbols/2010-08-25-crash.ll<br class="gmail_msg">
  test/Transforms/StripSymbols/strip-dead-debug-info.ll<br class="gmail_msg">
  test/Transforms/Util/strip-nonlinetable-debuginfo-containingtypes.ll<br class="gmail_msg">
  test/Verifier/DIGlobalVariable-no-unit.ll<br class="gmail_msg">
  test/tools/llvm-objdump/Hexagon/source-interleave-hexagon.ll<br class="gmail_msg">
  test/tools/llvm-objdump/X86/source-interleave-x86_64.ll<br class="gmail_msg">
  unittests/IR/MetadataTest.cpp<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></blockquote></div></div>