[PATCH] D139407: [llvm-objdump][AArch64] Fix ADRP target label calculation
Kristina Bessonova via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 13 07:18:32 PST 2022
krisb updated this revision to Diff 482465.
krisb added a comment.
Keep original test case and add another one.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139407/new/
https://reviews.llvm.org/D139407
Files:
llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
llvm/test/tools/llvm-objdump/ELF/AArch64/pcrel-address.yaml
Index: llvm/test/tools/llvm-objdump/ELF/AArch64/pcrel-address.yaml
===================================================================
--- llvm/test/tools/llvm-objdump/ELF/AArch64/pcrel-address.yaml
+++ llvm/test/tools/llvm-objdump/ELF/AArch64/pcrel-address.yaml
@@ -2,7 +2,8 @@
# RUN: llvm-objdump %t -d --no-show-raw-insn --no-leading-addr | FileCheck %s
# CHECK-LABEL: <_start>:
-# CHECK-NEXT: adrp x2, 0x220000 <_start+0x80>
+# CHECK-NEXT: adrp x2, 0x220000
+# CHECK-NEXT: adrp x2, 0x201000 <_start+0xf00>
--- !ELF
FileHeader:
@@ -15,7 +16,7 @@
Type: SHT_PROGBITS
Address: 0x200100
Flags: [SHF_ALLOC, SHF_EXECINSTR]
- Content: '02010090'
+ Content: '02010090020000B0'
- Name: .data
Type: SHT_PROGBITS
Flags: [SHF_ALLOC, SHF_WRITE]
Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
===================================================================
--- llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
+++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
@@ -412,8 +412,11 @@
const auto &Desc = Info->get(Inst.getOpcode());
for (unsigned i = 0, e = Inst.getNumOperands(); i != e; i++) {
if (Desc.OpInfo[i].OperandType == MCOI::OPERAND_PCREL) {
- int64_t Imm = Inst.getOperand(i).getImm() * 4;
- Target = Addr + Imm;
+ int64_t Imm = Inst.getOperand(i).getImm();
+ if (Inst.getOpcode() == AArch64::ADRP)
+ Target = (Addr & -4096) + Imm * 4096;
+ else
+ Target = Addr + Imm * 4;
return true;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139407.482465.patch
Type: text/x-patch
Size: 1594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221213/02cf09de/attachment.bin>
More information about the llvm-commits
mailing list