[PATCH] D96035: [WIP][dsymutil][DWARFlinker] implement separate multi-thread processing for compile units.

Alexey Lapshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 22 11:12:17 PST 2021


avl added a comment.

yep. this implementation is non-deterministic.
I tried to preserve the current ODR algorithm(which relies on concrete type sequences).

I thought about following improvement(though not for this patch),
which should be deterministic even in multi-thread mode:

Implement artificial type table with type merging:

Source DWARF:

  0x0000000b: DW_TAG_compile_unit 
                DW_AT_name = "module1.cpp"
                              
  0x0000002e: DW_TAG_structure_type 
                DW_AT_name = "S"
  
                NULL
  
  0x0000008c:   DW_TAG_subprogram 
  
  0x000000aa:     DW_TAG_variable  
                    DW_AT_name = "s"
                    DW_AT_type (0x0000002e "S")
  
              NULL
  
  0x0000012c: DW_TAG_compile_unit 
                DW_AT_name "module2.cpp"
  
  0x0000014f:   DW_TAG_structure_type 
                  DW_AT_name = "S"
  
  0x00000157:     DW_TAG_structure_type
                    DW_AT_name = "Nested"
  
  0x00000160: DW_TAG_subprogram 
  
  0x00000168:   DW_TAG_variable  
                     DW_AT_name = "n"
                     DW_AT_type (0x00000157 "Nested")
  
              NULL

New DWARF:

  0x0000000b: DW_TAG_compile_unit
                DW_AT_name = "__type_table"
  
  0x0000002e:   DW_TAG_structure_type 
                  DW_AT_name = "S"
  
  0x00000036:     DW_TAG_structure_type
                  DW_AT_name = "Nested"
  
                NULL
  
  0x0000012c: DW_TAG_compile_unit
                DW_AT_name = "module1.cpp"
  
  0x0000014c:   DW_TAG_subprogram 
  
  0x00000150:     DW_TAG_variable  
                    DW_AT_name = "s"
                    DW_AT_type (0x0000002e "S")
  
              NULL
  
  0x0000018c: DW_TAG_compile_unit
                DW_AT_name "module2.cpp"
  
  0x000001bc:   DW_TAG_subprogram 
  
  0x000001c0:     DW_TAG_variable  
                    DW_AT_name = "n"
                    DW_AT_type (0x00000036 "Nested")
  
              NULL

In this example, "New DWARF is the result of ODR unique algorithm differrent from the current one. 
The current ODR algorithm is - remember the first type occurrence and set all following references(to the same type) into that first met type.
The new ODR algorithm might be: move all types into separate artificial compile unit containing type table.
In this case type table might be always created in the same form despite the type processing order.

As additional bonus type merging might save noticeable amount of space.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96035/new/

https://reviews.llvm.org/D96035



More information about the llvm-commits mailing list