Skip to content

Commit 59c6f41

Browse files
committed
[LLD] [MachO] Fix GCC build warnings
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, ""); | ^~~~~~~~~~~~~~~~~~~~~~~~~ Differential Revision: https://reviews.llvm.org/D130970
1 parent 96d1218 commit 59c6f41

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lld/MachO/Arch/ARM64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ void OptimizationHintContext::applyAdrpLdr(const OptimizationHint &hint) {
445445
Optional<PerformedReloc> rel2 = findReloc(hint.offset0 + hint.delta[0]);
446446
if (!rel1 || !rel2)
447447
return;
448-
if (ldr.offset != (rel1->referentVA & 0xfff))
448+
if (ldr.offset != static_cast<int64_t>(rel1->referentVA & 0xfff))
449449
return;
450450
ldr.offset = rel1->referentVA - rel2->rel.offset - isec->getVA();
451451
if (!isLiteralLdrEligible(ldr))

lld/MachO/UnwindInfoSection.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,12 @@ static bool canFoldEncoding(compact_unwind_encoding_t encoding) {
401401
// of the unwind info's unwind address, two functions that have identical
402402
// unwind info can't be folded if it's using this encoding since both
403403
// entries need unique addresses.
404-
static_assert(UNWIND_X86_64_MODE_MASK == UNWIND_X86_MODE_MASK, "");
405-
static_assert(UNWIND_X86_64_MODE_STACK_IND == UNWIND_X86_MODE_STACK_IND, "");
404+
static_assert(static_cast<uint32_t>(UNWIND_X86_64_MODE_MASK) ==
405+
static_cast<uint32_t>(UNWIND_X86_MODE_MASK),
406+
"");
407+
static_assert(static_cast<uint32_t>(UNWIND_X86_64_MODE_STACK_IND) ==
408+
static_cast<uint32_t>(UNWIND_X86_MODE_STACK_IND),
409+
"");
406410
if ((target->cpuType == CPU_TYPE_X86_64 || target->cpuType == CPU_TYPE_X86) &&
407411
(encoding & UNWIND_X86_64_MODE_MASK) == UNWIND_X86_64_MODE_STACK_IND) {
408412
// FIXME: Consider passing in the two function addresses and getting

0 commit comments

Comments
 (0)