[PATCH] D130970: [LLD] [MachO] Fix GCC build warnings
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 2 01:05:39 PDT 2022
mstorsjo created this revision.
mstorsjo added reviewers: thakis, int3.
Herald added subscribers: pengfei, kristof.beyls.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
mstorsjo requested review of this revision.
Herald added a project: LLVM.
This fixes the following warnings produced by GCC 9:
../tools/lld/MachO/Arch/ARM64.cpp: In member function ‘void {anonymous}::OptimizationHintContext::applyAdrpLdr(const lld::macho::OptimizationHint&)’:
../tools/lld/MachO/Arch/ARM64.cpp:448:18: warning: comparison of integer expressions of different signedness: ‘int64_t’ {aka ‘long int’} and ‘uint64_t’ {aka ‘long unsigned int’} [-Wsign-compare]
448 | if (ldr.offset != (rel1->referentVA & 0xfff))
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../tools/lld/MachO/UnwindInfoSection.cpp: In function ‘bool canFoldEncoding(compact_unwind_encoding_t)’:
../tools/lld/MachO/UnwindInfoSection.cpp:404:44: warning: comparison between ‘enum<unnamed>’ and ‘enum<unnamed>’ [-Wenum-compare]
404 | static_assert(UNWIND_X86_64_MODE_MASK == UNWIND_X86_MODE_MASK, "");
| ^~~~~~~~~~~~~~~~~~~~
../tools/lld/MachO/UnwindInfoSection.cpp:405:49: warning: comparison between ‘enum<unnamed>’ and ‘enum<unnamed>’ [-Wenum-compare]
405 | static_assert(UNWIND_X86_64_MODE_STACK_IND == UNWIND_X86_MODE_STACK_IND, "");
| ^~~~~~~~~~~~~~~~~~~~~~~~~
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130970
Files:
lld/MachO/Arch/ARM64.cpp
lld/MachO/UnwindInfoSection.cpp
Index: lld/MachO/UnwindInfoSection.cpp
===================================================================
--- lld/MachO/UnwindInfoSection.cpp
+++ lld/MachO/UnwindInfoSection.cpp
@@ -401,8 +401,12 @@
// of the unwind info's unwind address, two functions that have identical
// unwind info can't be folded if it's using this encoding since both
// entries need unique addresses.
- static_assert(UNWIND_X86_64_MODE_MASK == UNWIND_X86_MODE_MASK, "");
- static_assert(UNWIND_X86_64_MODE_STACK_IND == UNWIND_X86_MODE_STACK_IND, "");
+ static_assert(static_cast<uint32_t>(UNWIND_X86_64_MODE_MASK) ==
+ static_cast<uint32_t>(UNWIND_X86_MODE_MASK),
+ "");
+ static_assert(static_cast<uint32_t>(UNWIND_X86_64_MODE_STACK_IND) ==
+ static_cast<uint32_t>(UNWIND_X86_MODE_STACK_IND),
+ "");
if ((target->cpuType == CPU_TYPE_X86_64 || target->cpuType == CPU_TYPE_X86) &&
(encoding & UNWIND_X86_64_MODE_MASK) == UNWIND_X86_64_MODE_STACK_IND) {
// FIXME: Consider passing in the two function addresses and getting
Index: lld/MachO/Arch/ARM64.cpp
===================================================================
--- lld/MachO/Arch/ARM64.cpp
+++ lld/MachO/Arch/ARM64.cpp
@@ -445,7 +445,7 @@
Optional<PerformedReloc> rel2 = findReloc(hint.offset0 + hint.delta[0]);
if (!rel1 || !rel2)
return;
- if (ldr.offset != (rel1->referentVA & 0xfff))
+ if (ldr.offset != static_cast<int64_t>(rel1->referentVA & 0xfff))
return;
ldr.offset = rel1->referentVA - rel2->rel.offset - isec->getVA();
if (!isLiteralLdrEligible(ldr))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130970.449210.patch
Type: text/x-patch
Size: 1619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220802/bea4e553/attachment.bin>
More information about the llvm-commits
mailing list