llvm-project/llvm/lib/Target/ARM/MCTargetDesc
Pavel Labath aaff1a631a 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

llvm-svn: 372710
2019-09-24 09:31:02 +00:00
..
ARMAddressingModes.h [ARM] Rename NEONModImm to VMOVModImm. NFC 2019-07-23 09:19:24 +00:00
ARMAsmBackend.cpp MCRegisterInfo: Merge getLLVMRegNum and getLLVMRegNumFromEH 2019-09-24 09:31:02 +00:00
ARMAsmBackend.h [ARM] Support .reloc *, R_ARM_NONE, * 2019-05-17 02:51:54 +00:00
ARMAsmBackendDarwin.h
ARMAsmBackendELF.h
ARMAsmBackendWinCOFF.h
ARMBaseInfo.h [ARM][MVE] Add invalidForTailPredication to TSFlags 2019-09-17 07:43:04 +00:00
ARMELFObjectWriter.cpp [MC] Minor cleanup to MCFixup::Kind handling. NFC. 2019-08-23 01:00:55 +00:00
ARMELFStreamer.cpp [AsmPrinter] Remove hidden flag -print-schedule. 2019-02-04 12:51:26 +00:00
ARMFixupKinds.h [ARM] Add the non-MVE instructions in Arm v8.1-M. 2019-06-11 09:29:18 +00:00
ARMInstPrinter.cpp [ARM] Rename NEONModImm to VMOVModImm. NFC 2019-07-23 09:19:24 +00:00
ARMInstPrinter.h [ARM] Rename NEONModImm to VMOVModImm. NFC 2019-07-23 09:19:24 +00:00
ARMMCAsmInfo.cpp
ARMMCAsmInfo.h
ARMMCCodeEmitter.cpp [ARM] Fix encoding of APSR in CLRM instruction 2019-08-13 16:12:46 +00:00
ARMMCExpr.cpp
ARMMCExpr.h
ARMMCTargetDesc.cpp [ARM] Add the non-MVE instructions in Arm v8.1-M. 2019-06-11 09:29:18 +00:00
ARMMCTargetDesc.h [ARM] Set up infrastructure for MVE vector instructions. 2019-06-13 13:11:13 +00:00
ARMMachORelocationInfo.cpp
ARMMachObjectWriter.cpp [MC] Minor cleanup to MCFixup::Kind handling. NFC. 2019-08-23 01:00:55 +00:00
ARMTargetStreamer.cpp [ARM] VFPv2 only supports 16 D registers. 2019-09-17 21:42:38 +00:00
ARMUnwindOpAsm.cpp
ARMUnwindOpAsm.h
ARMWinCOFFObjectWriter.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
ARMWinCOFFStreamer.cpp [MC] Pass through .code16/32/64 and .syntax unified for COFF 2019-09-03 18:16:52 +00:00
CMakeLists.txt [ARM] Move InstPrinter files to MCTargetDesc. NFC 2019-05-11 00:34:07 +00:00
LLVMBuild.txt [ARM] Move InstPrinter files to MCTargetDesc. NFC 2019-05-11 00:34:07 +00:00