Commit Graph

104 Commits

Author SHA1 Message Date
Amir Ayupov
fd38366e45 [BOLT][NFC] Clean includes, add license headers (#87200) 2024-03-31 19:29:45 -07:00
Amir Ayupov
c0febca3a6 [BOLT][NFC] Refactor BC::createBinaryContext for #81346 (#87172) 2024-03-30 20:43:23 -07:00
Alexander Yermolovich
105feb9ac6 [BOLT][DWARF] Fix handling of DW_TAG_label (#86182)
For DWARF5 BOLT was not retreiving address and instead was setting an
index.
Changed so that an address is used, and added DWARF4 test because it was
missing.
2024-03-22 13:41:27 -07:00
Jonas Devlieghere
41283403f5 [BOLT] Update DWARFRewriter for 32a6e9d669 2024-03-19 12:45:31 -07:00
Kazu Hirata
8af3f74294 Revert "[BOLT] Update DIEStreamer (#85818)"
This reverts commit e4f9175d23.

  commit 3176c15719
  Author: Andres Villegas <andresvi@google.com>
  Date:   Tue Mar 19 10:58:31 2024 -0700

reverted 43a2ec483f.
2024-03-19 12:37:32 -07:00
Kazu Hirata
e4f9175d23 [BOLT] Update DIEStreamer (#85818)
commit 43a2ec483f
  Author: Jonas Devlieghere <jonas@devlieghere.com>
  Date:   Tue Mar 19 08:30:47 2024 -0700

removed parameter Translator from the constructor of DwarfStreamer.
This patch fixes the build by updating the constructor of DIEStreamer
accordingly.
2024-03-19 12:21:18 -07:00
Mehdi Amini
4a4fb930a5 Use the new ThreadPoolInterface base class instead of the concrete implementation (NFC) (#84056) 2024-03-05 12:37:11 -08:00
Alexander Yermolovich
6de5fcc746 [BOLT][DWARF] Add support for .debug_names (#81062)
DWARF5 spec supports the .debug_names acceleration table. This is the
formalized version of combination of gdb-index/pubnames/types. Added
implementation of it to BOLT. It supports both monolothic and split
dwarf, with and without Type Units. It does not include parent indices.
This will be in followup PR. Unlike LLVM output this will put all the
CUs and TUs into one Module.
2024-02-26 14:00:31 -08:00
Alexander Yermolovich
640e781dc8 [BOLT][DWARF][NFC] Use SkeletonCU in place of IsDWO check (#82540)
Changed isDWO to a function that checks Skeleton CU that is passed in.
This is for preparation for
https://github.com/llvm/llvm-project/pull/81062.
2024-02-21 16:18:18 -08:00
Alexander Yermolovich
f81f7a5766 [BOLT][DWARF] Remove redundant code (#82118)
Removed some redundant code. Should be NFC change.
2024-02-17 12:37:07 -08:00
Alexander Yermolovich
5ff8b30327 [BOLT][DWARF] Do not emit zero low_pc address arange (#81955)
According to DWARF spec zero entires indicate end of arange. Changed so
that BOLT does not emit zero low_pc arange.
2024-02-16 11:23:28 -08:00
Alexander Yermolovich
82ca752393 [BOLT][DWARF] Add test for DW_AT_ranges input without function output (#81794)
Added a test that relies on -fbasic-block-sections=all and --gc-sections
that exercises a code path that previously printed a warning.
2024-02-14 15:43:39 -08:00
Amir Ayupov
52cf07116b [BOLT][NFC] Log through JournalingStreams (#81524)
Make core BOLT functionality more friendly to being used as a
library instead of in our standalone driver llvm-bolt. To
accomplish this, we augment BinaryContext with journaling streams
that are to be used by most BOLT code whenever something needs to
be logged to the screen. Users of the library can decide if logs
should be printed to a file, no file or to the screen, as
before. To illustrate this, this patch adds a new option
`--log-file` that allows the user to redirect BOLT logging to a
file on disk or completely hide it by using
`--log-file=/dev/null`. Future BOLT code should now use
`BinaryContext::outs()` for printing important messages instead of
`llvm::outs()`. A new test log.test enforces this by verifying that
no strings are print to screen once the `--log-file` option is
used.

In previous patches we also added a new BOLTError class to report
common and fatal errors, so code shouldn't call exit(1) now. To
easily handle problems as before (by quitting with exit(1)),
callers can now use
`BinaryContext::logBOLTErrorsAndQuitOnFatal(Error)` whenever code
needs to deal with BOLT errors. To test this, we have fatal.s
that checks we are correctly quitting and printing a fatal error
to the screen.

Because this is a significant change by itself, not all code was
yet ported. Code from Profiler libs (DataAggregator and friends)
still print errors directly to screen.

Co-authored-by: Rafael Auler <rafaelauler@fb.com>

Test Plan: NFC
2024-02-12 14:53:53 -08:00
Alexander Yermolovich
7d272722fb [BOLT][DWARF] Add option to specify DW_AT_comp_dir (#79395)
Added an --comp-dir-override option that overrides DW_AT_comp_dir in the
unit die. This allows for llvm-bolt to be invoked from any category and
still find .dwo files.
2024-01-25 15:00:52 -08:00
Alexander Yermolovich
bb6a485055 [BOLT] Fix updating DW_AT_stmt_list for DWARF5 TUs (#79374)
Changed so that we also update DW_AT_stmt_list for DWARF5 TUs. BOLT was
doing it for DWARF4, but it wasn't doing it for DWARF5.
2024-01-24 15:34:29 -08:00
avl-llvm
2357e899cb [DWARFLinker][DWARFLinkerParallel][NFC] Refactor DWARFLinker&DWARFLinkerParallel to have a common library. Part 1. (#75925)
This patch creates DWARFLinkerBase library, places DWARFLinker code into
DWARFLinker\Classic, places DWARFLinkerParallel into DWARFLinker\Parallel.
updates BOLT to use new library. This patch is NFC.
2024-01-09 11:32:08 +03:00
Alexander Yermolovich
bf2b035e58 [BOLT][DWARF] Fix handling .debug_str_offsets for type units (#75522)
There was an assumpiton that TUs and CUs share .debug_str_offsets
contribution. For ThinLTO builds it is not the case. Changed so that we
parse contributions for TUs also, and did some refactoring so that we
don't re-parse contributions that were not modified.
2023-12-14 17:27:21 -08:00
Alexander Yermolovich
fb9a851224 [BOLT][DWARF] Fix handling of debug_str_offsets (#75100)
We were not setting size field of .debug_str_offsets correctly. Fixed
it, and added a test.
2023-12-11 15:56:32 -08:00
Alexander Yermolovich
52be47b890 [BOLT][DWARF] Add support to create path (#73884)
When option --dwarf-output-path is specified, if the path does not exist
BOLT will now create it. This is what also happens when
--plugin-opt=dwo_dir=<value> is specified to LLD.
2023-11-30 09:41:01 -08:00
Maksim Panchenko
0acfe8483a [BOLT][DWARF] Fix output ranges for deleted code (#73464)
Set range low_pc to 0 for DIEs that correspond to deleted code.

Fixes #73428
2023-11-28 22:40:53 -08:00
Alexander Yermolovich
b47b3bee7b [BOLT][DWARF] Fix handling of DWARF5 DWP (#72729)
Fixed handling of DWP as input. Before BOLT crashed. Now it will write
out
correct CU, and all the TUs. Potential future improvement is to scan all
the TUs
used in this CU, and only include those.
2023-11-28 15:54:14 -08:00
Alexander Yermolovich
ce17c6d3ba [BOLT][DWARF] Fix --dwarf-output-path (#71886)
Fixed a bug where when --dwarf-output-path is specified
and DW_AT_dwo_name contains part of the path the output path would
contain both.
Which lead to llvm-bolt crash, because the path didn't exist.
Example:
llvm-bolt .... --dwarf-output-path=/some/path/ 
DW_AT_dwo_name  ("objects/o1/split.dwo")

It would try to write .dwo file to /some/path/objects/o1/split.dwo.dwo
instead of to
/some/path/split.dwo.dwo
2023-11-10 13:18:57 -08:00
spaette
1a2f83366b [BOLT] Fix typos (#68121)
Closes https://github.com/llvm/llvm-project/issues/63097

Before merging please make sure the change to
bolt/include/bolt/Passes/StokeInfo.h is correct.

bolt/include/bolt/Passes/StokeInfo.h

```diff
  //  This Pass solves the two major problems to use the Stoke program without
- //  proting its code:
+ //  probing its code:
```

I'm still not happy about the awkward wording in this comment.

bolt/include/bolt/Passes/FixRelaxationPass.h

```
$ ed -s bolt/include/bolt/Passes/FixRelaxationPass.h <<<'9,12p'
// This file declares the FixRelaxations class, which locates instructions with
// wrong targets and fixes them. Such problems usually occures when linker
// relaxes (changes) instructions, but doesn't fix relocations types properly
// for them.
$
```


bolt/docs/doxygen.cfg.in
bolt/include/bolt/Core/BinaryContext.h
bolt/include/bolt/Core/BinaryFunction.h
bolt/include/bolt/Core/BinarySection.h
bolt/include/bolt/Core/DebugData.h
bolt/include/bolt/Core/DynoStats.h
bolt/include/bolt/Core/Exceptions.h
bolt/include/bolt/Core/MCPlusBuilder.h
bolt/include/bolt/Core/Relocation.h
bolt/include/bolt/Passes/FixRelaxationPass.h
bolt/include/bolt/Passes/InstrumentationSummary.h
bolt/include/bolt/Passes/ReorderAlgorithm.h
bolt/include/bolt/Passes/StackReachingUses.h
bolt/include/bolt/Passes/StokeInfo.h
bolt/include/bolt/Passes/TailDuplication.h
bolt/include/bolt/Profile/DataAggregator.h
bolt/include/bolt/Profile/DataReader.h
bolt/lib/Core/BinaryContext.cpp
bolt/lib/Core/BinarySection.cpp
bolt/lib/Core/DebugData.cpp
bolt/lib/Core/DynoStats.cpp
bolt/lib/Core/Relocation.cpp
bolt/lib/Passes/Instrumentation.cpp
bolt/lib/Passes/JTFootprintReduction.cpp
bolt/lib/Passes/ReorderData.cpp
bolt/lib/Passes/RetpolineInsertion.cpp
bolt/lib/Passes/ShrinkWrapping.cpp
bolt/lib/Passes/TailDuplication.cpp
bolt/lib/Rewrite/BoltDiff.cpp
bolt/lib/Rewrite/DWARFRewriter.cpp
bolt/lib/Rewrite/RewriteInstance.cpp
bolt/lib/Utils/CommandLineOpts.cpp
bolt/runtime/instr.cpp
bolt/test/AArch64/got-ld64-relaxation.test
bolt/test/AArch64/unmarked-data.test
bolt/test/X86/Inputs/dwarf5-cu-no-debug-addr-helper.s
bolt/test/X86/Inputs/linenumber.cpp
bolt/test/X86/double-jump.test
bolt/test/X86/dwarf5-call-pc-function-null-check.test
bolt/test/X86/dwarf5-split-dwarf4-monolithic.test
bolt/test/X86/dynrelocs.s
bolt/test/X86/fallthrough-to-noop.test
bolt/test/X86/tail-duplication-cache.s
bolt/test/runtime/X86/instrumentation-ind-calls.s
2023-11-09 11:29:46 -08:00
maksfb
6e26246c22 [BOLT][DWARF] Refactor address ranges processing (#71225)
Create BinaryFunction::translateInputToOutputRange() and use it for
updating DWARF debug ranges and location lists while de-duplicating the
existing code. Additionally, move DWARF-specific code out of
BinaryFunction and add print functions to facilitate debugging.

Note that this change is deliberately kept "bug-level" compatible with
the existing solution to keep it NFCI and make it easier to track any
possible regressions in the future updates to the ranges-handling code.
2023-11-06 11:10:20 -08:00
Eymen Ünay
d7add58cff [BOLT] Fix typo in comment
Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D157206
2023-08-24 09:37:48 -07:00
Alexander Yermolovich
bce5743e21 [BOLT][DWARF] Fix location list order
This bug crept in when CU partitioning was introduced. It manifests itself when
there are CUs that use location lists that come before CUs that are part of
thin-lto. BOLT processes CUs with cross CU references first (these are produced
by thin-lto). When we wrote out all the location lists we did it in original
order. Since DWARF4 uses offsets directly in to .debug_loc those offsets in DIEs
became wrong.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D157908
2023-08-14 17:27:22 -07:00
Alexander Yermolovich
55a1d959a5 [BOLT][DWARF] Always use new low_pc for call_site
Changed to creating a new index all the time. This code was legacy of when we
couldn't change the size of .debug_info, and led to subtle bugs where index for
new entries was pointing to a wrong address.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D157356
2023-08-08 18:21:24 -07:00
Alexander Yermolovich
96cfc5f840 [BOLT][DWARF] Always use new low_pc for exprloc
Changed to creating a new index all the time. This code was legacy of when we
couldn't change the size of .debug_info, and led to subtle bugs where index for
new entries was pointing to a wrong address.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D157355
2023-08-08 18:20:06 -07:00
Alexander Yermolovich
9ffdc2b457 [BOLT][DWARF][NFC] Add function to print DIE
This is purely to make debugging easier for developers. Now that we moved to IR
the print out of DIEs is lacking. This function will lazily parse DIE and use
DWARFDie dump function.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D157354
2023-08-08 18:18:24 -07:00
Alexander Yermolovich
e1ceae4b60 [BOLT][DWARF] Fix setting DW_AT_ranges offset of Skeleton CU
Fixed a bug where when Skelton CU had DW_AT_ranges, it the output CU DW_AT_ranges
 offset was relative, and not absolute.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D156958
2023-08-03 10:34:21 -07:00
Alexander Yermolovich
efb8a1c906 [BOLT][DWARF] Delete DW_AT_low_pc when converting to ranges
Now that we have new DWARF Rewriter we can remove DW_AT_low_pc when converting
DW_AT_low_pc/DW_AT_high_pc to DW_AT_ranges. Which closer follows DWARF spec.
Leaving CU DW_AT_low_pc in place. Reading the spec I think it's needed.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D156957
2023-08-03 10:33:04 -07:00
Alexander Yermolovich
9eb0df3aa9 [BOLT][DWARF] Fix handling of inlined subroutine with no output PC
Clang can generate DW_TAG_inlined_subroutine with low_pc 0. With split dwarf
this led to range offset being a negative number.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D156742
2023-07-31 17:12:07 -07:00
Alexander Yermolovich
75f770a68f [BOLT][DWARF] Update handling of size 1 ranges and fix sub-programs with ranges
When output range is only one entry, and input is low_pc/high_pc do not convert
to ranges. This helps with size of .debug_ranges/.debug_rnglists. It also helps
when either low_pc/high_pc is 0. We not generating potentially invalid ranges
that result in LLDB error.

Also fixed handling of DW_AT_subprogram with ranges. This can be created with
-fbasic-block-sections=all.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D156374
2023-07-30 17:32:32 -07:00
Alexander Yermolovich
790b75ea36 [BOLT][DWARF] Fix adding DW_AT_GNU_ranges_base
There are cases in DWARF4 when Skeleton CU has ranges, but dwo CU doesn't.
Bug was introduced in new DWARFRewriter where for DWARF4 it would fall through
to DWARF5 case.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D155033
2023-07-13 10:54:48 -07:00
Alexander Yermolovich
4940128ace [BOLT][DWARF][NFC] Fix false positive error
The DWO Unit DIE, doesn't have low_pc/high_pc, so we were printing this error
for valid cases.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D155032
2023-07-13 10:50:19 -07:00
Alexander Yermolovich
dcfa2ab534 [BOLT][DWARF] Change to process and write out TUs first then CUs in batches
To reduce memory footprint changed so that we process and write out TUs first,
reset DIEBuilder and process CUs. CUs are processed in buckets. First bucket
contains all the CUs with cross CU references. Rest processd one at a time.

clang-17 build in debug mode, by clang-17.
before
8:25.81 real, 834.37 user, 86.03 sys, 0 amem, 79525064 mmem
8:02.20 real, 820.46 user, 81.81 sys, 0 amem, 79501616 mmem
7:52.69 real, 802.01 user, 83.99 sys, 0 amem, 79534392 mmem

after
7:49.35 real, 822.04 user, 66.19 sys, 0 amem, 34934260 mmem
7:42.16 real, 825.46 user, 63.52 sys, 0 amem, 34951660 mmem
7:46.71 real, 821.11 user, 63.14 sys, 0 amem, 34981164 mmem

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D151909
2023-07-10 14:42:04 -07:00
Alexander Yermolovich
8362418748 [BOLT][DWARF] Output DWO files as they are being processed
Changed how we handle writing out .dwo and .dwp files. We now write out DWO
sections sooner and destroy DIEBuilder. This should decrease memory footprint.

Ran on clang-17 build in debug mode with split-dwarf.
before
8:07.49 real,   664.62 user,    69.00 sys,      0 amem, 41601612 mmem
8:07.06 real,   669.60 user,    68.75 sys,      0 amem, 41822588 mmem
8:00.36 real,   664.14 user,    66.36 sys,      0 amem, 41561548 mmem

after
8:21.85 real,   682.23 user,    69.64 sys,      0 amem, 39379880 mmem
8:04.58 real,   671.62 user,    66.50 sys,      0 amem, 39735800 mmem
8:10.02 real,   680.67 user,    67.24 sys,       0 amem, 39662888 mmem

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D151908
2023-07-10 14:42:04 -07:00
Alexander Yermolovich
c33536e9c3 [BOLT][DWARF] Numerous fixes for a new DWARFRewriter
* Some cleanup and minor fixes for the new debug information re-writer before moving on
to productatization.

* The new rewriter wasn't handling binary with DWARF5 and DWARF4 with
-fdebug-types-sections.

* Removed dead cross cu reference code.

* Added support for DW_AT_sibling.

* With the new re-writer abbrev number can change which can lead to offset of Type
Units changing. Before we would just copy raw data. Changed to write out Type
Unit List. This is generated by gdb-add-index.

* Fixed how bolt handles gdb-index generated by gdb-11 with types sections.
Simplified logic that handles variations of gdb-index.

* Clang can generate two type units with the same hash, but different content. LLD
does not de-duplicate when ThinLTO is involved. Changed so that TU hash and
offset are used to make TU's unique.

* It is possible to have references within location expression to another DIE.
Fixed it so that relative offset is updated correctly.

* Removed all the code related to patching.

* Removed dead code. Changed how we handling writting out TUs and TU Index. It now
  should fully work for DWARF4 and DWARF5.

* Removed unused arguments from some APIs, changed return type to void, and other
small cleanups.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D151906
2023-07-10 14:42:03 -07:00
Rui Zhong
87fb0ea27e [BOLT][DWARF] Implement new mechanism for DWARFRewriter
This revision implement new mechanism for DWARFRewriter.
In the new mechanism, we adopt the same way with DWARFLinker did.
By parsing Debug information into IR, we are allowed to handle debug information more flexible.
Now the debug information updating process relies on IR and IR will be written out to binary once the updating finished.

A new class was added: DIEBuilder. This class is responsible for parsing debug information and raising it to the IR level.
This class is also used to write out the .debug_info and .debug_abbrev sections.
Since we output brand new Abbrev section we won't need to always convert low_pc/high_pc into ranges.
When conversion does happen we can also remove low_pc entry.

Reviewed By: maksfb, ayermolo

Differential Revision: https://reviews.llvm.org/D130315
2023-07-10 14:42:03 -07:00
Nico Weber
de7781ea42 Revert "[DWARF][BOLT] Implement new mechanism for DWARFRewriter"
This reverts commit 460a224443.
It breaks building on macOS, and it was landed with a review URL
pointing to some Facebook-internal service.

Also reverts a bunch of follow-ups:

Revert "[BOLT][DWARF] Don't check string offsets"
This reverts commit f9d6f48c8b.

Revert "[BOLT][DWARF] Change to process and write out TUs first then CUs in batches"
This reverts commit 88e95c1e4b.

Revert "[BOLT][DWARF] Output DWO files as they are being processed"
This reverts commit 46ca2e3fcd.

Revert "[BOLT][DWARF] Don't check string offsets"
This reverts commit cfe4a4b04f.

Revert "[BOLT][DWARF] Numerous fixes for a new DWARFRewriter"
This reverts commit 2701a661da.
2023-07-07 08:07:01 -04:00
Alexander Yermolovich
88e95c1e4b [BOLT][DWARF] Change to process and write out TUs first then CUs in batches
Summary:
To reduce memory footprint changed so that we process and write out TUs first,
reset DIEBuilder and process CUs. CUs are processed in buckets. First bucket
contains all the CUs with cross CU references. Rest processd one at a time.

clang-17 build in debug mode, by clang-17.
before
8:25.81 real, 834.37 user, 86.03 sys, 0 amem, 79525064 mmem
8:02.20 real, 820.46 user, 81.81 sys, 0 amem, 79501616 mmem
7:52.69 real, 802.01 user, 83.99 sys, 0 amem, 79534392 mmem

after
7:49.35 real, 822.04 user, 66.19 sys, 0 amem, 34934260 mmem
7:42.16 real, 825.46 user, 63.52 sys, 0 amem, 34951660 mmem
7:46.71 real, 821.11 user, 63.14 sys, 0 amem, 34981164 mmem

Differential Revision: https://phabricator.intern.facebook.com/D45883198
2023-07-06 14:21:26 -07:00
Alexander Yermolovich
46ca2e3fcd [BOLT][DWARF] Output DWO files as they are being processed
Summary:
Changed how we handle writing out .dwo and .dwp files. We now write out DWO
sections sooner and destroy DIEBuilder. This should decrease memory footprint.

Ran on clang-17 build in debug mode with split-dwarf.
before
8:07.49 real,   664.62 user,    69.00 sys,      0 amem, 41601612 mmem
8:07.06 real,   669.60 user,    68.75 sys,      0 amem, 41822588 mmem
8:00.36 real,   664.14 user,    66.36 sys,      0 amem, 41561548 mmem

after
8:21.85 real,   682.23 user,    69.64 sys,      0 amem, 39379880 mmem
8:04.58 real,   671.62 user,    66.50 sys,      0 amem, 39735800 mmem
8:10.02 real,   680.67 user,    67.24 sys,       0 amem, 39662888 mmem

Differential Revision: https://phabricator.intern.facebook.com/D45458889
2023-07-06 14:21:26 -07:00
Alexander Yermolovich
2701a661da [BOLT][DWARF] Numerous fixes for a new DWARFRewriter
Summary:

* Some cleanup and minor fixes for the new debug information re-writer before moving on
to productatization.

* The new rewriter wasn't handling binary with DWARF5 and DWARF4 with
-fdebug-types-sections.

* Removed dead cross cu reference code.

* Added support for DW_AT_sibling.

* With the new re-writer abbrev number can change which can lead to offset of Type
Units changing. Before we would just copy raw data. Changed to write out Type
Unit List. This is generated by gdb-add-index.

* Fixed how bolt handles gdb-index generated by gdb-11 with types sections.
Simplified logic that handles variations of gdb-index.

* Clang can generate two type units with the same hash, but different content. LLD
does not de-duplicate when ThinLTO is involved. Changed so that TU hash and
offset are used to make TU's unique.

* It is possible to have references within location expression to another DIE.
Fixed it so that relative offset is updated correctly.

* Removed all the code related to patching.

* Removed dead code. Changed how we handling writting out TUs and TU Index. It now
  should fully work for DWARF4 and DWARF5.

* Removed unused arguments from some APIs, changed return type to void, and other
small cleanups.

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: https://phabricator.intern.facebook.com/D46168257
2023-07-06 14:21:26 -07:00
Alexander Yermolovich
460a224443 [DWARF][BOLT] Implement new mechanism for DWARFRewriter
Summary:
This revision implement new mechanism for DWARFRewriter.
In the new mechanism, we adopt the same way with DWARFLinker did.
By parsing Debug information into IR, we are allowed to handle debug information more flexible.
Now the debug information updating process relies on IR and IR will be written out to binary once the updating finished.

A new class was added: DIEBuilder. This class is responsible for parsing debug information and raising it to the IR level.
This class is also used to write out the .debug_info and .debug_abbrev sections.
Since we output brand new Abbrev section we won't need to always convert low_pc/high_pc into ranges.
When conversion does happen we can also remove low_pc entry.

Differential Revision: https://phabricator.intern.facebook.com/D39484421

Tasks: T117448832
2023-07-06 14:21:26 -07:00
Alexander Yermolovich
01ef213b85 [BOLT][DWARF] Fix handling of GCed CU function
A CU can have only one function so CU will have low_pc/high_pc. If this funciton
is GCed by LLD low_pc will become 0x0, and BOLT can't map this to output. We
kind of were getting away with it in monolithic DWARF, but with split DWARF
there is only skeleton CU, so we end up with rnglist with header and array, but
no body. This caused LLDB to report an error.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D151845
2023-06-01 12:06:47 -07:00
Alexander Yermolovich
640e07c490 [BOLT][DWARF][NFC] Fixed an assertion check
Spotted this one while working on new DWARF Rewriter. We were using wrong check
in assertion.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D150167
2023-05-09 11:37:40 -07:00
Alexander Yermolovich
125df67421 [BOLT][DWARF] Fix handling of CUs without TU reference
When input is DWP with DWARF5 bolt wasn't handling correctly CUs that didn't
have TU references. Which resulted in a crash.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D148589
2023-04-17 17:56:08 -07:00
Alexander Yermolovich
7fc7934023 [llvm][dwwarf] Change CU/TU index to 64-bit
Changed contribution data structure to 64 bit. I added the 32bit and 64bit
accessors to make it explicit where we use 32bit and where we use 64bit. Also to
make sure sure we catch all the cases where this data structure is used.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D139379
2023-01-11 15:07:11 -08:00
Alexander Yermolovich
6a4a697e17 Revert "[llvm][dwwarf] Change CU/TU index to 64-bit"
This reverts commit fa3fa4d0d4.
2023-01-11 14:41:24 -08:00
Alexander Yermolovich
fa3fa4d0d4 [llvm][dwwarf] Change CU/TU index to 64-bit
Changed contribution data structure to 64 bit. I added the 32bit and 64bit
accessors to make it explicit where we use 32bit and where we use 64bit. Also to
make sure sure we catch all the cases where this data structure is used.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D139379
2023-01-10 10:33:52 -08:00