[llvm] 97f0f5b - [MC, NVPTX] Fix warnings
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 12:10:33 PDT 2024
Author: Kazu Hirata
Date: 2024-09-26T12:10:27-07:00
New Revision: 97f0f5b574d36e3252966c455cfb3a687b4f5325
URL: https://github.com/llvm/llvm-project/commit/97f0f5b574d36e3252966c455cfb3a687b4f5325
DIFF: https://github.com/llvm/llvm-project/commit/97f0f5b574d36e3252966c455cfb3a687b4f5325.diff
LOG: [MC, NVPTX] Fix warnings
This patch fixes:
llvm/include/llvm/MC/MCRegisterInfo.h:146:7: error:
'llvm::MCRegisterInfo' has virtual functions but non-virtual
destructor [-Werror,-Wnon-virtual-dtor]
llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp:163:21: error:
comparison of integers of different signs: 'int' and 'size_type'
(aka 'unsigned long') [-Werror,-Wsign-compare]
Added:
Modified:
llvm/include/llvm/MC/MCRegisterInfo.h
llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCRegisterInfo.h b/llvm/include/llvm/MC/MCRegisterInfo.h
index 8a6f9fce97e30c..6db42878d2e521 100644
--- a/llvm/include/llvm/MC/MCRegisterInfo.h
+++ b/llvm/include/llvm/MC/MCRegisterInfo.h
@@ -268,6 +268,8 @@ class MCRegisterInfo {
friend class MCRegUnitRootIterator;
friend class MCRegAliasIterator;
+ virtual ~MCRegisterInfo() {}
+
/// Initialize MCRegisterInfo, called by TableGen
/// auto-generated routines. *DO NOT USE*.
void InitMCRegisterInfo(const MCRegisterDesc *D, unsigned NR, unsigned RA,
diff --git a/llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp b/llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp
index 97673f78685f59..c30372fed1832d 100644
--- a/llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp
@@ -160,11 +160,8 @@ static uint64_t encodeRegisterForDwarf(std::string registerName) {
// number, which is stored in ULEB128, but in practice must be no more than 8
// bytes (excluding null terminator, which is not included).
uint64_t result = 0;
- for (int i = 0; i < registerName.length(); ++i) {
- result = result << 8;
- unsigned char c = registerName[i];
- result |= c;
- }
+ for (unsigned char c : registerName)
+ result = (result << 8) | c;
return result;
}
More information about the llvm-commits
mailing list