[llvm] [llvm] use 64-bit types for result of getDwarfRegNum (NFC) (PR #109494)
Walter Erquinigo via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 22 13:28:52 PDT 2024
================
@@ -151,24 +151,28 @@ int MCRegisterInfo::getDwarfRegNum(MCRegister RegNum, bool isEH) const {
const DwarfLLVMRegPair *I = std::lower_bound(M, M+Size, Key);
if (I == M+Size || I->FromReg != RegNum)
return -1;
- return I->ToReg;
+ // Consumers need to be able to detect -1 and -2, but at various points
+ // the numbers move between unsigned and signed representations, as well as
+ // between 32- and 64-bit representations. We need to convert first to int
+ // before int64_t for proper sign handling.
+ return int64_t(int(I->ToReg));
----------------
walter-erquinigo wrote:
what about doing the following:
```
auto reg = I->ToReg;
switch (reg) {
case -1: return -1;
case -2: return -2;
default: return reg;
}
```
https://github.com/llvm/llvm-project/pull/109494
More information about the llvm-commits
mailing list