[llvm] r349800 - [MC] [AArch64] Correctly resolve ":abs_g1:3" etc.
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 20 11:46:14 PST 2018
Author: efriedma
Date: Thu Dec 20 11:46:14 2018
New Revision: 349800
URL: http://llvm.org/viewvc/llvm-project?rev=349800&view=rev
Log:
[MC] [AArch64] Correctly resolve ":abs_g1:3" etc.
We have to treat constructs like this as if they were "symbolic", to use
the correct codepath to resolve them. This mostly only affects movz
etc. because the other uses of classifySymbolRef conservatively treat
everything that isn't a constant as if it were a symbol.
Differential Revision: https://reviews.llvm.org/D55906
Modified:
llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/trunk/test/MC/AArch64/fixup-absolute.s
Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=349800&r1=349799&r2=349800&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Thu Dec 20 11:46:14 2018
@@ -5434,10 +5434,16 @@ AArch64AsmParser::classifySymbolRef(cons
// Check that it looks like a symbol + an addend
MCValue Res;
bool Relocatable = Expr->evaluateAsRelocatable(Res, nullptr, nullptr);
- if (!Relocatable || !Res.getSymA() || Res.getSymB())
+ if (!Relocatable || Res.getSymB())
return false;
- DarwinRefKind = Res.getSymA()->getKind();
+ // Treat expressions with an ELFRefKind (like ":abs_g1:3", or
+ // ":abs_g1:x" where x is constant) as symbolic even if there is no symbol.
+ if (!Res.getSymA() && ELFRefKind == AArch64MCExpr::VK_INVALID)
+ return false;
+
+ if (Res.getSymA())
+ DarwinRefKind = Res.getSymA()->getKind();
Addend = Res.getConstant();
// It's some symbol reference + a constant addend, but really
Modified: llvm/trunk/test/MC/AArch64/fixup-absolute.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/fixup-absolute.s?rev=349800&r1=349799&r2=349800&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/fixup-absolute.s (original)
+++ llvm/trunk/test/MC/AArch64/fixup-absolute.s Thu Dec 20 11:46:14 2018
@@ -1,21 +1,40 @@
// RUN: llvm-mc -triple aarch64--none-eabi -filetype obj < %s -o - | llvm-objdump -d - | FileCheck %s
+onepart_before = 0x1234
+twopart_before = 0x12345678
+threepart_before = 0x1234567890AB
+fourpart_before = 0x1234567890ABCDEF
+
+// CHECK: mov x0, #1311673391471656960
// CHECK: mov x0, #1311673391471656960
-movz x0, #:abs_g3:fourpart
+movz x0, #:abs_g3:fourpart_before
+movz x0, #:abs_g3:fourpart_after
// CHECK: mov x0, #20014547599360
-movz x0, #:abs_g2:threepart
+// CHECK: mov x0, #20014547599360
+movz x0, #:abs_g2:threepart_before
+movz x0, #:abs_g2:threepart_after
+// CHECK: movk x0, #22136, lsl #32
// CHECK: movk x0, #22136, lsl #32
-movk x0, #:abs_g2_nc:fourpart
+movk x0, #:abs_g2_nc:fourpart_before
+movk x0, #:abs_g2_nc:fourpart_after
// CHECK: mov x0, #305397760
-movz x0, #:abs_g1:twopart
+// CHECK: mov x0, #305397760
+movz x0, #:abs_g1:twopart_before
+movz x0, #:abs_g1:twopart_after
+// CHECK: movk x0, #37035, lsl #16
// CHECK: movk x0, #37035, lsl #16
-movk x0, #:abs_g1_nc:fourpart
+movk x0, #:abs_g1_nc:fourpart_before
+movk x0, #:abs_g1_nc:fourpart_after
// CHECK: mov x0, #4660
-movz x0, #:abs_g0:onepart
+// CHECK: mov x0, #4660
+movz x0, #:abs_g0:onepart_before
+movz x0, #:abs_g0:onepart_after
+// CHECK: movk x0, #52719
// CHECK: movk x0, #52719
-movk x0, #:abs_g0_nc:fourpart
+movk x0, #:abs_g0_nc:fourpart_before
+movk x0, #:abs_g0_nc:fourpart_after
-onepart = 0x1234
-twopart = 0x12345678
-threepart = 0x1234567890AB
-fourpart = 0x1234567890ABCDEF
+onepart_after = 0x1234
+twopart_after = 0x12345678
+threepart_after = 0x1234567890AB
+fourpart_after = 0x1234567890ABCDEF
More information about the llvm-commits
mailing list