Skip to content

Commit e42b897

Browse files
committed
rebase
Created using spr 1.3.5-bogner
2 parents 34ce16c + 32f83d3 commit e42b897

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+621
-632
lines changed

llvm/include/llvm/MC/MCFixup.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ enum MCFixupKind : uint16_t {
3434
FK_Data_4, ///< A four-byte fixup.
3535
FK_Data_8, ///< A eight-byte fixup.
3636
FK_Data_leb128, ///< A leb128 fixup.
37-
FK_PCRel_1, ///< A one-byte pc relative fixup.
38-
FK_PCRel_2, ///< A two-byte pc relative fixup.
39-
FK_PCRel_4, ///< A four-byte pc relative fixup.
40-
FK_PCRel_8, ///< A eight-byte pc relative fixup.
4137
FK_SecRel_1, ///< A one-byte section relative fixup.
4238
FK_SecRel_2, ///< A two-byte section relative fixup.
4339
FK_SecRel_4, ///< A four-byte section relative fixup.

llvm/lib/MC/MCAsmBackend.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ MCFixupKindInfo MCAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
9595
{"FK_Data_4", 0, 32, 0},
9696
{"FK_Data_8", 0, 64, 0},
9797
{"FK_Data_leb128", 0, 0, 0},
98-
{"FK_PCRel_1", 0, 8, 0},
99-
{"FK_PCRel_2", 0, 16, 0},
100-
{"FK_PCRel_4", 0, 32, 0},
101-
{"FK_PCRel_8", 0, 64, 0},
10298
{"FK_SecRel_1", 0, 8, 0},
10399
{"FK_SecRel_2", 0, 16, 0},
104100
{"FK_SecRel_4", 0, 32, 0},

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,9 +2414,14 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
24142414
auto Kind = F.getKind();
24152415
if (mc::isRelocation(Kind))
24162416
OS << ", relocation type: " << Kind;
2417-
else
2418-
OS << ", kind: "
2419-
<< getAssembler().getBackend().getFixupKindInfo(Kind).Name;
2417+
else {
2418+
OS << ", kind: ";
2419+
auto Info = getAssembler().getBackend().getFixupKindInfo(Kind);
2420+
if (F.isPCRel() && StringRef(Info.Name).starts_with("FK_Data_"))
2421+
OS << "FK_PCRel_" << (Info.TargetSize / 8);
2422+
else
2423+
OS << Info.Name;
2424+
}
24202425
OS << '\n';
24212426
}
24222427
}

llvm/lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFObjectWriter.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,18 @@ unsigned AArch64WinCOFFObjectWriter::getRelocType(
4949
MCContext &Ctx, const MCValue &Target, const MCFixup &Fixup,
5050
bool IsCrossSection, const MCAsmBackend &MAB) const {
5151
unsigned FixupKind = Fixup.getKind();
52+
bool PCRel = Fixup.isPCRel();
5253
if (IsCrossSection) {
5354
// IMAGE_REL_ARM64_REL64 does not exist. We treat FK_Data_8 as FK_PCRel_4 so
5455
// that .xword a-b can lower to IMAGE_REL_ARM64_REL32. This allows generic
5556
// instrumentation to not bother with the COFF limitation. A negative value
5657
// needs attention.
57-
if (FixupKind != FK_Data_4 && FixupKind != FK_Data_8) {
58+
if (PCRel || (FixupKind != FK_Data_4 && FixupKind != FK_Data_8)) {
5859
Ctx.reportError(Fixup.getLoc(), "Cannot represent this expression");
5960
return COFF::IMAGE_REL_ARM64_ADDR32;
6061
}
61-
FixupKind = FK_PCRel_4;
62+
FixupKind = FK_Data_4;
63+
PCRel = true;
6264
}
6365

6466
auto Spec = Target.getSpecifier();
@@ -93,10 +95,9 @@ unsigned AArch64WinCOFFObjectWriter::getRelocType(
9395
return COFF::IMAGE_REL_ARM64_ABSOLUTE; // Dummy return value
9496
}
9597

96-
case FK_PCRel_4:
97-
return COFF::IMAGE_REL_ARM64_REL32;
98-
9998
case FK_Data_4:
99+
if (PCRel)
100+
return COFF::IMAGE_REL_ARM64_REL32;
100101
switch (Spec) {
101102
default:
102103
return COFF::IMAGE_REL_ARM64_ADDR32;

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
9494
return 2;
9595
case FK_SecRel_4:
9696
case FK_Data_4:
97-
case FK_PCRel_4:
9897
return 4;
9998
case FK_SecRel_8:
10099
case FK_Data_8:
@@ -121,7 +120,6 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
121120
case FK_Data_2:
122121
case FK_Data_4:
123122
case FK_Data_8:
124-
case FK_PCRel_4:
125123
case FK_SecRel_4:
126124
return Value;
127125
default:

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ unsigned AMDGPUELFObjectWriter::getRelocType(const MCFixup &Fixup,
6969
MCFixupKind Kind = Fixup.getKind();
7070
switch (Kind) {
7171
default: break;
72-
case FK_PCRel_4:
73-
return ELF::R_AMDGPU_REL32;
7472
case FK_Data_4:
7573
case FK_SecRel_4:
7674
return IsPCRel ? ELF::R_AMDGPU_REL32 : ELF::R_AMDGPU_ABS32;

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCCodeEmitter.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -656,16 +656,11 @@ void AMDGPUMCCodeEmitter::getMachineOpValueCommon(
656656
//
657657
// .Ltmp1:
658658
// s_add_u32 s2, s2, (extern_const_addrspace+16)-.Ltmp1
659-
MCFixupKind Kind;
660-
if (needsPCRel(MO.getExpr()))
661-
Kind = FK_PCRel_4;
662-
else
663-
Kind = FK_Data_4;
664-
659+
bool PCRel = needsPCRel(MO.getExpr());
665660
const MCInstrDesc &Desc = MCII.get(MI.getOpcode());
666661
uint32_t Offset = Desc.getSize();
667662
assert(Offset == 4 || Offset == 8);
668-
addFixup(Fixups, Offset, MO.getExpr(), Kind, Kind == FK_PCRel_4);
663+
addFixup(Fixups, Offset, MO.getExpr(), FK_Data_4, PCRel);
669664
}
670665

671666
const MCInstrDesc &Desc = MCII.get(MI.getOpcode());

llvm/lib/Target/ARM/MCTargetDesc/ARMWinCOFFObjectWriter.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ unsigned ARMWinCOFFObjectWriter::getRelocType(MCContext &Ctx,
4747
const MCAsmBackend &MAB) const {
4848
auto Spec = Target.getSpecifier();
4949
unsigned FixupKind = Fixup.getKind();
50+
bool PCRel = false;
5051
if (IsCrossSection) {
51-
if (FixupKind != FK_Data_4) {
52+
if (PCRel || FixupKind != FK_Data_4) {
5253
Ctx.reportError(Fixup.getLoc(), "Cannot represent this expression");
5354
return COFF::IMAGE_REL_ARM_ADDR32;
5455
}
55-
FixupKind = FK_PCRel_4;
56+
FixupKind = FK_Data_4;
57+
PCRel = true;
5658
}
5759

5860

@@ -62,6 +64,8 @@ unsigned ARMWinCOFFObjectWriter::getRelocType(MCContext &Ctx,
6264
return COFF::IMAGE_REL_ARM_ABSOLUTE;
6365
}
6466
case FK_Data_4:
67+
if (PCRel)
68+
return COFF::IMAGE_REL_ARM_REL32;
6569
switch (Spec) {
6670
case MCSymbolRefExpr::VK_COFF_IMGREL32:
6771
return COFF::IMAGE_REL_ARM_ADDR32NB;
@@ -70,8 +74,6 @@ unsigned ARMWinCOFFObjectWriter::getRelocType(MCContext &Ctx,
7074
default:
7175
return COFF::IMAGE_REL_ARM_ADDR32;
7276
}
73-
case FK_PCRel_4:
74-
return COFF::IMAGE_REL_ARM_REL32;
7577
case FK_SecRel_2:
7678
return COFF::IMAGE_REL_ARM_SECTION;
7779
case FK_SecRel_4:

llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ void BPFAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
7878
support::endian::write<uint32_t>(&Data[Fixup.getOffset() + 4],
7979
static_cast<uint32_t>(Value),
8080
Endian);
81-
} else if (Fixup.getKind() == FK_Data_4) {
81+
} else if (Fixup.getKind() == FK_Data_4 && !Fixup.isPCRel()) {
8282
support::endian::write<uint32_t>(&Data[Fixup.getOffset()], Value, Endian);
8383
} else if (Fixup.getKind() == FK_Data_8) {
8484
support::endian::write<uint64_t>(&Data[Fixup.getOffset()], Value, Endian);
85-
} else if (Fixup.getKind() == FK_PCRel_4) {
85+
} else if (Fixup.getKind() == FK_Data_4 && Fixup.isPCRel()) {
8686
Value = (uint32_t)((Value - 8) / 8);
8787
if (Endian == llvm::endianness::little) {
8888
Data[Fixup.getOffset() + 1] = 0x10;
@@ -97,7 +97,7 @@ void BPFAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
9797
support::endian::write<uint32_t>(&Data[Fixup.getOffset() + 4], Value,
9898
Endian);
9999
} else {
100-
assert(Fixup.getKind() == FK_PCRel_2);
100+
assert(Fixup.getKind() == FK_Data_2 && Fixup.isPCRel());
101101

102102
int64_t ByteOff = (int64_t)Value - 8;
103103
if (ByteOff > INT16_MAX * 8 || ByteOff < INT16_MIN * 8)

llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ unsigned BPFELFObjectWriter::getRelocType(const MCFixup &Fixup,
4545
case FK_SecRel_8:
4646
// LD_imm64 instruction.
4747
return ELF::R_BPF_64_64;
48-
case FK_PCRel_4:
49-
// CALL instruction.
50-
return ELF::R_BPF_64_32;
5148
case FK_Data_8:
5249
return ELF::R_BPF_64_ABS64;
5350
case FK_Data_4:
51+
if (Fixup.isPCRel()) // CALL instruction
52+
return ELF::R_BPF_64_32;
5453
if (const auto *A = Target.getAddSym()) {
5554
const MCSymbol &Sym = *A;
5655

0 commit comments

Comments
 (0)