llvm/lib/DebugInfo/DWARF
Pavel Labath d93e5a30d0 MCRegisterInfo: Merge getLLVMRegNum and getLLVMRegNumFromEH
Summary:
The functions different in two ways:
- getLLVMRegNum could return both "eh" and "other" dwarf register
  numbers, while getLLVMRegNumFromEH only returned the "eh" number.
- getLLVMRegNum asserted if the register was not found, while the second
  function returned -1.

The second distinction was pretty important, but it was very hard to
infer that from the function name. Aditionally, for the use case of
dumping dwarf expressions, we needed a function which can work with both
kinds of number, but does not assert.

This patch solves both of these issues by merging the two functions into
one, returning an Optional<unsigned> value. While the same thing could
be achieved by adding an "IsEH" argument to the (renamed)
getLLVMRegNumFromEH function, it seemed better to avoid the confusion of
two functions and put the choice of asserting into the hands of the
caller -- if he checks the Optional value, he can safely process
"untrusted" input, and if he blindly dereferences the Optional, he gets
the assertion.

I've updated all call sites to the new API, choosing between the two
options according to the function they were calling originally, except
that I've updated the usage in DWARFExpression.cpp to use the "safe"
method instead, and added a test case which would have previously
triggered an assertion failure when processing (incorrect?) dwarf
expressions.

Reviewers: dsanders, arsenm, JDevlieghere

Subscribers: wdng, aprantl, javed.absar, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67154

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372710 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-24 09:31:02 +00:00
..
CMakeLists.txt [DWARF] Revert r345546: Refactor range list extraction and dumping 2018-10-31 01:12:58 +00:00
DWARFAbbreviationDeclaration.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFAcceleratorTable.cpp Remove support for 32-bit offsets in utility classes (5/5) 2019-08-07 11:44:47 +00:00
DWARFAddressRange.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DWARFCompileUnit.cpp [DWARF] Adjust return type of DWARFUnit::getLength(). 2019-08-21 14:10:57 +00:00
DWARFContext.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
DWARFDataExtractor.cpp Add error handling to the DataExtractor class 2019-08-27 11:24:08 +00:00
DWARFDebugAbbrev.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFDebugAddr.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFDebugAranges.cpp DebugInfo/DWARF: Normalize DWARFObject members on the DWARF spec section names 2019-08-07 17:18:11 +00:00
DWARFDebugArangeSet.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFDebugFrame.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
DWARFDebugInfoEntry.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFDebugLine.cpp [DebugLine] Don't try to guess the path style 2019-08-15 23:53:15 +00:00
DWARFDebugLoc.cpp DWARF: Fix a regression in location list dumping 2019-09-04 10:09:12 +00:00
DWARFDebugMacro.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFDebugPubTable.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFDebugRangeList.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFDebugRnglists.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFDie.cpp DWARF: Fix a regression in location list dumping 2019-09-04 10:09:12 +00:00
DWARFExpression.cpp MCRegisterInfo: Merge getLLVMRegNum and getLLVMRegNumFromEH 2019-09-24 09:31:02 +00:00
DWARFFormValue.cpp Remove support for 32-bit offsets in utility classes (5/5) 2019-08-07 11:44:47 +00:00
DWARFGdbIndex.cpp Switch LLVM to use 64-bit offsets (2/5) 2019-08-06 10:49:40 +00:00
DWARFListTable.cpp [DWARF] Support DWARF64 in DWARFListTableHeader. 2019-09-05 06:49:05 +00:00
DWARFTypeUnit.cpp [DWARF] Adjust return type of DWARFUnit::getLength(). 2019-08-21 14:10:57 +00:00
DWARFUnit.cpp [DWARF] Fix referencing Range List Tables from CUs for DWARF64. 2019-09-05 07:02:28 +00:00
DWARFUnitIndex.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
DWARFVerifier.cpp [DWARFVerifier] Verify GNU extensions of call site DWARF symbols 2019-09-02 09:20:46 +00:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00