[PATCH] D32648: Remove line and file from DINamespace

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 09:42:34 PDT 2017


aprantl created this revision.
Herald added a subscriber: mehdi_amini.

Fixes the issue highlighted in http://lists.llvm.org/pipermail/cfe-dev/2014-June/037500.html.

The DW_AT_decl_file and DW_AT_decl_line attributes on namespaces prevent LLVM from uniquing types that are in the same namespace. They also don't carry any meaningful information.

Here's the canonical example of why this is broken:

  $ cat test1.cpp
  #include "test.h" // namespace test is in test.h
  test::Test<int> foo1() {
     return test::Test<int>();
  }
  
  $ cat test2.cpp
  namespace test { // namespace test is in test2.cpp
  }
  #include "test.h"
  test::Test<int> foo2() {
     return test::Test<int>();
  }
  
  $ cat test.h
  namespace test {
  template <class T>
  class Test {
  };
  }
  
  $ clang++ -g -emit-llvm test1.cpp -S -o test1.ll
  $ clang++ -g -emit-llvm test2.cpp -S -o test2.ll
  $ llvm-link test1.ll test2.ll -S -o linked.ll
  $ llc linked.ll

This patch removes the line and file attribute from DINamespace, and generates anonymous namespaces as distinct to prevent uniquing where it would be incorrect. The discussion in the linked thread predates distinct MDNodes which was the missing ingredient to make this happen.

rdar://problem/17484998


Repository:
  rL LLVM

https://reviews.llvm.org/D32648

Files:
  include/llvm/IR/DIBuilder.h
  include/llvm/IR/DebugInfoMetadata.h
  lib/AsmParser/LLParser.cpp
  lib/Bitcode/Reader/MetadataLoader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  lib/IR/AsmWriter.cpp
  lib/IR/DIBuilder.cpp
  lib/IR/DebugInfoMetadata.cpp
  lib/IR/LLVMContextImpl.h
  test/Assembler/dinamespace.ll
  test/Bitcode/DINamespace.ll
  test/CodeGen/X86/stack-protector-dbginfo.ll
  test/CodeGenCXX/debug-info-anon-namespace.cpp
  test/DebugInfo/COFF/cpp-mangling.ll
  test/DebugInfo/COFF/scopes.ll
  test/DebugInfo/Generic/dwarf-public-names.ll
  test/DebugInfo/Generic/namespace.ll
  test/DebugInfo/Generic/namespace_function_definition.ll
  test/DebugInfo/Generic/namespace_inline_function_definition.ll
  test/DebugInfo/X86/dwarf-linkage-names.ll
  test/DebugInfo/X86/dwarf-public-names.ll
  test/DebugInfo/X86/generate-odr-hash.ll
  test/DebugInfo/X86/gnu-public-names-tu.ll
  test/DebugInfo/X86/gnu-public-names.ll
  test/DebugInfo/X86/inline-namespace.ll
  test/DebugInfo/X86/lexical-block-file-inline.ll
  test/DebugInfo/X86/multiple-at-const-val.ll
  test/DebugInfo/X86/parameters.ll
  test/DebugInfo/X86/pr19307.ll
  test/DebugInfo/X86/union-template.ll
  test/Linker/2011-08-18-unique-class-type.ll
  test/Linker/2011-08-18-unique-class-type2.ll
  test/Linker/pr26037.ll
  test/ThinLTO/X86/debuginfo-cu-import.ll
  tools/clang/lib/CodeGen/CGDebugInfo.cpp
  tools/clang/test/CodeGenCXX/debug-info-namespace.cpp
  tools/clang/test/Modules/ExtDebugInfo.cpp
  unittests/IR/MetadataTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32648.97112.patch
Type: text/x-patch
Size: 45621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170428/0b2157f5/attachment.bin>


More information about the llvm-commits mailing list