[llvm] 3a90c27 - [MC] Remove an overload of isSymbolRefDifferenceFullyResolvedImpl
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 29 16:26:47 PDT 2024
Author: Fangrui Song
Date: 2024-06-29T16:26:42-07:00
New Revision: 3a90c27385e9a8b50e40a307822906a1303c310b
URL: https://github.com/llvm/llvm-project/commit/3a90c27385e9a8b50e40a307822906a1303c310b
DIFF: https://github.com/llvm/llvm-project/commit/3a90c27385e9a8b50e40a307822906a1303c310b.diff
LOG: [MC] Remove an overload of isSymbolRefDifferenceFullyResolvedImpl
e3a20f57d927e422874a8e7730bb7590515b586d (2015) overloaded
isSymbolRefDifferenceFullyResolvedImpl with the IsPCRel parameter.
The overload without IsPCRel is only customized by Mach-O to
dsiable `.long L_var4 - L_var3` folding in
darwin-x86_64-diff-reloc-assign-2.s, but that seems unnecessary.
Added:
Modified:
llvm/include/llvm/MC/MCMachObjectWriter.h
llvm/include/llvm/MC/MCObjectWriter.h
llvm/lib/MC/MCObjectWriter.cpp
llvm/lib/MC/MachObjectWriter.cpp
llvm/test/MC/MachO/darwin-x86_64-diff-reloc-assign-2.s
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCMachObjectWriter.h b/llvm/include/llvm/MC/MCMachObjectWriter.h
index 1683543082e28..70515c9f6d2fe 100644
--- a/llvm/include/llvm/MC/MCMachObjectWriter.h
+++ b/llvm/include/llvm/MC/MCMachObjectWriter.h
@@ -254,11 +254,6 @@ class MachObjectWriter : public MCObjectWriter {
void executePostLayoutBinding(MCAssembler &Asm,
const MCAsmLayout &Layout) override;
- bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
- const MCSymbol &A,
- const MCSymbol &B,
- bool InSet) const override;
-
bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
const MCSymbol &SymA,
const MCFragment &FB, bool InSet,
diff --git a/llvm/include/llvm/MC/MCObjectWriter.h b/llvm/include/llvm/MC/MCObjectWriter.h
index e66bb2c932dd0..0b21853ea85ae 100644
--- a/llvm/include/llvm/MC/MCObjectWriter.h
+++ b/llvm/include/llvm/MC/MCObjectWriter.h
@@ -78,11 +78,6 @@ class MCObjectWriter {
const MCSymbolRefExpr *B,
bool InSet) const;
- virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
- const MCSymbol &A,
- const MCSymbol &B,
- bool InSet) const;
-
virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
const MCSymbol &SymA,
const MCFragment &FB,
diff --git a/llvm/lib/MC/MCObjectWriter.cpp b/llvm/lib/MC/MCObjectWriter.cpp
index 559aff130d880..d321e581bbf0e 100644
--- a/llvm/lib/MC/MCObjectWriter.cpp
+++ b/llvm/lib/MC/MCObjectWriter.cpp
@@ -29,17 +29,11 @@ bool MCObjectWriter::isSymbolRefDifferenceFullyResolved(
const MCSymbol &SA = A->getSymbol();
const MCSymbol &SB = B->getSymbol();
assert(!SA.isUndefined() && !SB.isUndefined());
- if (!SA.getFragment() || !SB.getFragment())
+ MCFragment *FB = SB.getFragment();
+ if (!FB || !SA.getFragment())
return false;
- return isSymbolRefDifferenceFullyResolvedImpl(Asm, SA, SB, InSet);
-}
-
-bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
- const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B,
- bool InSet) const {
- return isSymbolRefDifferenceFullyResolvedImpl(Asm, A, *B.getFragment(), InSet,
- false);
+ return isSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *FB, InSet, /*IsPCRel=*/false);
}
bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index b98ca3cc53fc3..0ef449575f73d 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -661,18 +661,6 @@ void MachObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
bindIndirectSymbols(Asm);
}
-bool MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
- const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B,
- bool InSet) const {
- // FIXME: We don't handle things like
- // foo = .
- // creating atoms.
- if (A.isVariable() || B.isVariable())
- return false;
- return MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(Asm, A, B,
- InSet);
-}
-
bool MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB,
bool InSet, bool IsPCRel) const {
diff --git a/llvm/test/MC/MachO/darwin-x86_64-
diff -reloc-assign-2.s b/llvm/test/MC/MachO/darwin-x86_64-
diff -reloc-assign-2.s
index b01857ed8c38a..d076c9eebdf5a 100644
--- a/llvm/test/MC/MachO/darwin-x86_64-
diff -reloc-assign-2.s
+++ b/llvm/test/MC/MachO/darwin-x86_64-
diff -reloc-assign-2.s
@@ -9,20 +9,4 @@ L_var2:
.long L_var4 - L_var3
// CHECK: Relocations [
-// CHECK-NEXT: Section __data {
-// CHECK-NEXT: Relocation {
-// CHECK-NEXT: Offset: 0x4
-// CHECK-NEXT: PCRel: 0
-// CHECK-NEXT: Length: 2
-// CHECK-NEXT: Type: X86_64_RELOC_SUBTRACTOR (5)
-// CHECK-NEXT: Section: __data (2)
-// CHECK-NEXT: }
-// CHECK-NEXT: Relocation {
-// CHECK-NEXT: Offset: 0x4
-// CHECK-NEXT: PCRel: 0
-// CHECK-NEXT: Length: 2
-// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
-// CHECK-NEXT: Section: __data (2)
-// CHECK-NEXT: }
-// CHECK-NEXT: }
// CHECK-NEXT: ]
More information about the llvm-commits
mailing list