[llvm] r248428 - dsymutil: Don't prune forward declarations inside a module definition.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 13:58:27 PDT 2015


> On Sep 23, 2015, at 1:53 PM, David Blaikie <dblaikie at gmail.com> wrote:
> 
> 
> 
> On Wed, Sep 23, 2015 at 1:44 PM, Adrian Prantl via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> Author: adrian
> Date: Wed Sep 23 15:44:37 2015
> New Revision: 248428
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=248428&view=rev <http://llvm.org/viewvc/llvm-project?rev=248428&view=rev>
> Log:
> dsymutil: Don't prune forward declarations inside a module definition.
> 
> Does dsymutil pull in the definitions from modules? (if so, why are there DW_TAG_modules left in the DWARF at all?)

It pulls in the entire* module and converts all references to module type fwddecls in other CUs into DW_FORM_ref_addr forms pointing to the definition in the module. (* fwddecls for types imported from a third module are pruned). The DW_TAG_modules stay in so a consumer can choose to imported types directly from the AST using the extra DW_AT_llvm attributes in the TAG_module to import the module.

— adrian 
>  
> 
> Modified:
>     llvm/trunk/test/tools/dsymutil/Inputs/modules/1.o
>     llvm/trunk/test/tools/dsymutil/Inputs/modules/Bar.pcm
>     llvm/trunk/test/tools/dsymutil/Inputs/modules/Foo.pcm
>     llvm/trunk/test/tools/dsymutil/X86/modules.m
>     llvm/trunk/tools/dsymutil/DwarfLinker.cpp
> 
> Modified: llvm/trunk/test/tools/dsymutil/Inputs/modules/1.o
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/modules/1.o?rev=248428&r1=248427&r2=248428&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/modules/1.o?rev=248428&r1=248427&r2=248428&view=diff>
> ==============================================================================
> Binary files llvm/trunk/test/tools/dsymutil/Inputs/modules/1.o (original) and llvm/trunk/test/tools/dsymutil/Inputs/modules/1.o Wed Sep 23 15:44:37 2015 differ
> 
> Modified: llvm/trunk/test/tools/dsymutil/Inputs/modules/Bar.pcm
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/modules/Bar.pcm?rev=248428&r1=248427&r2=248428&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/modules/Bar.pcm?rev=248428&r1=248427&r2=248428&view=diff>
> ==============================================================================
> Binary files llvm/trunk/test/tools/dsymutil/Inputs/modules/Bar.pcm (original) and llvm/trunk/test/tools/dsymutil/Inputs/modules/Bar.pcm Wed Sep 23 15:44:37 2015 differ
> 
> Modified: llvm/trunk/test/tools/dsymutil/Inputs/modules/Foo.pcm
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/modules/Foo.pcm?rev=248428&r1=248427&r2=248428&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/modules/Foo.pcm?rev=248428&r1=248427&r2=248428&view=diff>
> ==============================================================================
> Binary files llvm/trunk/test/tools/dsymutil/Inputs/modules/Foo.pcm (original) and llvm/trunk/test/tools/dsymutil/Inputs/modules/Foo.pcm Wed Sep 23 15:44:37 2015 differ
> 
> Modified: llvm/trunk/test/tools/dsymutil/X86/modules.m
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/X86/modules.m?rev=248428&r1=248427&r2=248428&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/X86/modules.m?rev=248428&r1=248427&r2=248428&view=diff>
> ==============================================================================
> --- llvm/trunk/test/tools/dsymutil/X86/modules.m (original)
> +++ llvm/trunk/test/tools/dsymutil/X86/modules.m Wed Sep 23 15:44:37 2015
> @@ -9,8 +9,8 @@
>         export *
>       }
>     EOF
> -   clang -D BAR_H -E -o Bar.h
> -   clang -D FOO_H -E -o Foo.h
> +   clang -D BAR_H -E -o Bar.h modules.m
> +   clang -D FOO_H -E -o Foo.h modules.m
>     clang -cc1 -emit-obj -fmodules -fmodule-map-file=modules.modulemap \
>       -fmodule-format=obj -g -dwarf-ext-refs -fmodules-cache-path=. \
>       -fdisable-module-hash modules.m -o 1.o
> @@ -32,17 +32,22 @@
>  // CHECK-NOT:        DW_TAG
>  // CHECK:              DW_TAG_module
>  // CHECK-NEXT:           DW_AT_name{{.*}}"Bar"
> -// CHECK-NOT:            DW_TAG
>  // CHECK: 0x0[[BAR:.*]]: DW_TAG_structure_type
> +// CHECK-NOT:              DW_TAG
>  // CHECK:                  DW_AT_name {{.*}}"Bar"
>  // CHECK-NOT:              DW_TAG
>  // CHECK:                  DW_TAG_member
>  // CHECK:                    DW_AT_name {{.*}}"value"
> +// CHECK:                DW_TAG_structure_type
> +// CHECK-NOT:              DW_TAG
> +// CHECK:                  DW_AT_name {{.*}}"PruneMeNot"
> 
>  struct Bar {
>    int value;
>  };
> 
> +struct PruneMeNot;
> +
>  #else
>  // ---------------------------------------------------------------------
>  #ifdef FOO_H
> 
> Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=248428&r1=248427&r2=248428&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=248428&r1=248427&r2=248428&view=diff>
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
> +++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Wed Sep 23 15:44:37 2015
> @@ -1764,7 +1764,7 @@ static bool analyzeContextInfo(const DWA
>                                 DeclContext *CurrentDeclContext,
>                                 NonRelocatableStringpool &StringPool,
>                                 DeclContextTree &Contexts,
> -                               bool InTagModule = false) {
> +                               bool InImportedModule = false) {
>    unsigned MyIdx = CU.getOrigUnit().getDIEIndex(DIE);
>    CompileUnit::DIEInfo &Info = CU.getInfo(MyIdx);
> 
> @@ -1780,11 +1780,14 @@ static bool analyzeContextInfo(const DWA
>    //   definitions match)."
>    //
>    // We treat non-C++ modules like namespaces for this reason.
> -  if (DIE->getTag() == dwarf::DW_TAG_module)
> -    InTagModule = true;
> +  if (DIE->getTag() == dwarf::DW_TAG_module &&
> +      DIE->getAttributeValueAsString(&CU.getOrigUnit(), dwarf::DW_AT_name,
> +                                     "") != CU.getClangModuleName()) {
> +    InImportedModule = true;
> +  }
> 
>    Info.ParentIdx = ParentIdx;
> -  if (CU.hasODR() || CU.isClangModule() || InTagModule) {
> +  if (CU.hasODR() || CU.isClangModule() || InImportedModule) {
>      if (CurrentDeclContext) {
>        auto PtrInvalidPair = Contexts.getChildDeclContext(*CurrentDeclContext,
>                                                           DIE, CU, StringPool);
> @@ -1795,12 +1798,12 @@ static bool analyzeContextInfo(const DWA
>        Info.Ctxt = CurrentDeclContext = nullptr;
>    }
> 
> -  Info.Prune = InTagModule;
> +  Info.Prune = InImportedModule;
>    if (DIE->hasChildren())
>      for (auto *Child = DIE->getFirstChild(); Child && !Child->isNULL();
>           Child = Child->getSibling())
>        Info.Prune &= analyzeContextInfo(Child, MyIdx, CU, CurrentDeclContext,
> -                                       StringPool, Contexts, InTagModule);
> +                                       StringPool, Contexts, InImportedModule);
> 
>    // Prune this DIE if it is either a forward declaration inside a
>    // DW_TAG_module or a DW_TAG_module that contains nothing but
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150923/0cffc119/attachment-0001.html>


More information about the llvm-commits mailing list