[llvm] 1b11b5b - [AArch64] Replace fixup_aarch64_tlsdesc_call with FirstLiteralRelocationKind + R_AARCH64_{,P32_}TLSDESC_CALL
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed May 5 17:42:01 PDT 2021
Author: Fangrui Song
Date: 2021-05-05T17:41:56-07:00
New Revision: 1b11b5b01fd8887a9c471b10cd99f0a60f6b2e50
URL: https://github.com/llvm/llvm-project/commit/1b11b5b01fd8887a9c471b10cd99f0a60f6b2e50
DIFF: https://github.com/llvm/llvm-project/commit/1b11b5b01fd8887a9c471b10cd99f0a60f6b2e50.diff
LOG: [AArch64] Replace fixup_aarch64_tlsdesc_call with FirstLiteralRelocationKind + R_AARCH64_{,P32_}TLSDESC_CALL
Added:
Modified:
llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64FixupKinds.h
llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp
llvm/test/MC/AArch64/tls-relocs.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
index 6af2dd69cefc..1f6f95b6a9e5 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -67,8 +67,7 @@ class AArch64AsmBackend : public MCAsmBackend {
{"fixup_aarch64_pcrel_branch14", 5, 14, PCRelFlagVal},
{"fixup_aarch64_pcrel_branch19", 5, 19, PCRelFlagVal},
{"fixup_aarch64_pcrel_branch26", 0, 26, PCRelFlagVal},
- {"fixup_aarch64_pcrel_call26", 0, 26, PCRelFlagVal},
- {"fixup_aarch64_tlsdesc_call", 0, 0, 0}};
+ {"fixup_aarch64_pcrel_call26", 0, 26, PCRelFlagVal}};
// Fixup kinds from .reloc directive are like R_AARCH64_NONE. They do not
// require any extra processing.
@@ -109,9 +108,6 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
default:
llvm_unreachable("Unknown fixup kind!");
- case AArch64::fixup_aarch64_tlsdesc_call:
- return 0;
-
case FK_Data_1:
return 1;
@@ -367,7 +363,6 @@ unsigned AArch64AsmBackend::getFixupKindContainereSizeInBytes(unsigned Kind) con
case FK_Data_8:
return 8;
- case AArch64::fixup_aarch64_tlsdesc_call:
case AArch64::fixup_aarch64_movw:
case AArch64::fixup_aarch64_pcrel_branch14:
case AArch64::fixup_aarch64_add_imm12:
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
index fcf67bd2f740..2f9c17245b5f 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
@@ -444,8 +444,6 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
Ctx.reportError(Fixup.getLoc(),
"invalid fixup for movz/movk instruction");
return ELF::R_AARCH64_NONE;
- case AArch64::fixup_aarch64_tlsdesc_call:
- return R_CLS(TLSDESC_CALL);
default:
Ctx.reportError(Fixup.getLoc(), "Unknown ELF relocation type");
return ELF::R_AARCH64_NONE;
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64FixupKinds.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64FixupKinds.h
index fe8043fe5ec0..767dd8805520 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64FixupKinds.h
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64FixupKinds.h
@@ -55,9 +55,6 @@ enum Fixups {
// branch26 only on ELF.
fixup_aarch64_pcrel_call26,
- // zero-space placeholder for the ELF R_AARCH64_TLSDESC_CALL relocation.
- fixup_aarch64_tlsdesc_call,
-
// Marker
LastTargetFixupKind,
NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp
index da8f511c650f..1fd0d33aabfd 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp
@@ -599,8 +599,12 @@ void AArch64MCCodeEmitter::encodeInstruction(const MCInst &MI, raw_ostream &OS,
// This is a directive which applies an R_AARCH64_TLSDESC_CALL to the
// following (BLR) instruction. It doesn't emit any code itself so it
// doesn't go through the normal TableGenerated channels.
- MCFixupKind Fixup = MCFixupKind(AArch64::fixup_aarch64_tlsdesc_call);
- Fixups.push_back(MCFixup::create(0, MI.getOperand(0).getExpr(), Fixup));
+ auto Reloc = STI.getTargetTriple().getEnvironment() == Triple::GNUILP32
+ ? ELF::R_AARCH64_P32_TLSDESC_CALL
+ : ELF::R_AARCH64_TLSDESC_CALL;
+ Fixups.push_back(
+ MCFixup::create(0, MI.getOperand(0).getExpr(),
+ MCFixupKind(FirstLiteralRelocationKind + Reloc)));
return;
}
diff --git a/llvm/test/MC/AArch64/tls-relocs.s b/llvm/test/MC/AArch64/tls-relocs.s
index 5194048c5b62..47243c28bc7a 100644
--- a/llvm/test/MC/AArch64/tls-relocs.s
+++ b/llvm/test/MC/AArch64/tls-relocs.s
@@ -388,7 +388,7 @@
// CHECK: add x5, x4, :tlsdesc_lo12:var // encoding: [0x85,0bAAAAAA00,0b00AAAAAA,0x91]
// CHECK: // fixup A - offset: 0, value: :tlsdesc_lo12:var, kind: fixup_aarch64_add_imm12
// CHECK: .tlsdesccall var // encoding: []
-// CHECK: // fixup A - offset: 0, value: var, kind: fixup_aarch64_tlsdesc_call
+// CHECK-NEXT: // fixup A - offset: 0, value: var, kind: FK_NONE
// CHECK: blr x3 // encoding: [0x60,0x00,0x3f,0xd6]
// CHECK-ELF-NEXT: 0x104 R_AARCH64_TLSDESC_ADR_PAGE21 [[VARSYM]]
More information about the llvm-commits
mailing list