[llvm] 840e3b0 - AArch64: Reject label difference with a relocation specifier in generic assembler code

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 28 00:15:03 PDT 2025


Author: Fangrui Song
Date: 2025-08-28T00:14:59-07:00
New Revision: 840e3b03c959f638434b7ad56c01d3819cdace3e

URL: https://github.com/llvm/llvm-project/commit/840e3b03c959f638434b7ad56c01d3819cdace3e
DIFF: https://github.com/llvm/llvm-project/commit/840e3b03c959f638434b7ad56c01d3819cdace3e.diff

LOG: AArch64: Reject label difference with a relocation specifier in generic assembler code

... instead of within AArch64ELFObjectWriter. Aligns with other targets.

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
    llvm/test/MC/AArch64/error-location.s
    llvm/test/MC/AArch64/label-arithmetic-diags-elf.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
index 828c5c5462407..d2ba100e5c6dc 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
@@ -124,7 +124,7 @@ static bool evaluate(const MCSpecifierExpr &Expr, MCValue &Res,
   if (!Expr.getSubExpr()->evaluateAsRelocatable(Res, Asm))
     return false;
   Res.setSpecifier(Expr.getSpecifier());
-  return true;
+  return !Res.getSubSym();
 }
 
 AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin(bool IsILP32) {

diff  --git a/llvm/test/MC/AArch64/error-location.s b/llvm/test/MC/AArch64/error-location.s
index 758e4db9bc2e0..c2ce2fe4059ac 100644
--- a/llvm/test/MC/AArch64/error-location.s
+++ b/llvm/test/MC/AArch64/error-location.s
@@ -22,7 +22,7 @@
 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: 1-byte data relocations not supported
   .byte undef-.
 
-// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Unsupported pc-relative fixup kind
+// CHECK: :[[@LINE+1]]:16: error: expected relocatable expression
   ldr x0, [x1, :lo12:undef-.]
 
 // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: invalid fixup for 8-bit load/store instruction

diff  --git a/llvm/test/MC/AArch64/label-arithmetic-diags-elf.s b/llvm/test/MC/AArch64/label-arithmetic-diags-elf.s
index ff53d01e5feda..365183b2390b4 100644
--- a/llvm/test/MC/AArch64/label-arithmetic-diags-elf.s
+++ b/llvm/test/MC/AArch64/label-arithmetic-diags-elf.s
@@ -49,24 +49,14 @@ negative:
   // CHECK-NEXT: ^
 
   add w0, w1, #:lo12:external - end
-  // CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: Unsupported pc-relative fixup kind
+  // CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: expected relocatable expression
   // CHECK-NEXT: add w0, w1, #:lo12:external - end
-  // CHECK-NEXT: ^
 
   cmp w0, #:lo12:external - end
-  // CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: Unsupported pc-relative fixup kind
-  // CHECK-NEXT: cmp w0, #:lo12:external - end
-  // CHECK-NEXT: ^
+  // CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: expected relocatable expression
 
   add w0, w1, #:got_lo12:external - end
-  // CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: Unsupported pc-relative fixup kind
-  // CHECK-NEXT: add w0, w1, #:got_lo12:external - end
-  // CHECK-NEXT: ^
-
-  cmp w0, #:got_lo12:external - end
-  // CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: Unsupported pc-relative fixup kind
-  // CHECK-NEXT: cmp w0, #:got_lo12:external - end
-  // CHECK-NEXT: ^
+  // CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: expected relocatable expression
 
   .section sec_y
 end_across_sec:


        


More information about the llvm-commits mailing list