llvm-project/llvm/lib/Target/X86/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
..
CMakeLists.txt [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
LLVMBuild.txt [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
X86ATTInstPrinter.cpp [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
X86ATTInstPrinter.h [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
X86AsmBackend.cpp MCRegisterInfo: Merge getLLVMRegNum and getLLVMRegNumFromEH 2019-09-24 09:31:02 +00:00
X86BaseInfo.h [X86] Remove string literal from an if. NFC 2019-05-02 21:57:18 +00:00
X86ELFObjectWriter.cpp [MC] Minor cleanup to MCFixup::Kind handling. NFC. 2019-08-23 01:00:55 +00:00
X86FixupKinds.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
X86InstComments.cpp [X86] Introduce new MOVSSrm/MOVSDrm opcodes that use VR128 register class. 2019-06-18 03:23:11 +00:00
X86InstComments.h [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
X86InstPrinterCommon.cpp [X86] Add VP2INTERSECT instructions 2019-05-31 02:50:41 +00:00
X86InstPrinterCommon.h [X86] Add VP2INTERSECT instructions 2019-05-31 02:50:41 +00:00
X86IntelInstPrinter.cpp [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
X86IntelInstPrinter.h [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
X86MCAsmInfo.cpp Allow '@' to appear in x86 mingw symbols 2019-08-29 21:15:02 +00:00
X86MCAsmInfo.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
X86MCCodeEmitter.cpp [X86] Fix x86-64 call *foo@tlsdesc(%rax) and support R_386_TLSGOTDESC R_386_TLS_DESC_CALL 2019-05-29 02:02:59 +00:00
X86MCExpr.h [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
X86MCTargetDesc.cpp [X86][Btver2] Fix latency and throughput of CMPXCHG instructions. 2019-08-20 10:23:55 +00:00
X86MCTargetDesc.h [X86][Btver2] Fix latency and throughput of CMPXCHG instructions. 2019-08-20 10:23:55 +00:00
X86MachObjectWriter.cpp [MC] Minor cleanup to MCFixup::Kind handling. NFC. 2019-08-23 01:00:55 +00:00
X86TargetStreamer.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
X86WinCOFFObjectWriter.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
X86WinCOFFStreamer.cpp [MC] Avoid crashes from improperly nested or wrong target .seh_handlerdata directives 2019-08-30 22:25:55 +00:00
X86WinCOFFTargetStreamer.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00