[PATCH] D136742: [llvm][LoongArch] Improve the "out of range" error information reported by `adjustFixupValue`, NFC

Xiaodong Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 23:41:16 PDT 2022


XiaodongLoong created this revision.
XiaodongLoong added reviewers: SixWeining, wangleiat.
Herald added a subscriber: hiraditya.
Herald added a project: All.
XiaodongLoong requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

There are three reduplicate error messages for different conditions. I
add meaningful information to make them more informative.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136742

Files:
  llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
  llvm/test/MC/LoongArch/Relocations/fixups-diagnostics.s


Index: llvm/test/MC/LoongArch/Relocations/fixups-diagnostics.s
===================================================================
--- llvm/test/MC/LoongArch/Relocations/fixups-diagnostics.s
+++ llvm/test/MC/LoongArch/Relocations/fixups-diagnostics.s
@@ -1,10 +1,10 @@
 # RUN: not llvm-mc --triple=loongarch64 --filetype=obj %s -o /dev/null 2>&1 | FileCheck %s
 
-  beq $a0, $a1, far_distant # CHECK: :[[#@LINE]]:3: error: fixup value out of range
+  beq $a0, $a1, far_distant # CHECK: :[[#@LINE]]:3: error: fixup value out of range represented by 18 bit
   bne $a0, $a1, unaligned # CHECK: :[[#@LINE]]:3: error: fixup value must be 4-byte aligned
 
   bnez $a0, unaligned # CHECK: :[[#@LINE]]:3: error: fixup value must be 4-byte aligned
-  beqz $a0, far_distant_bz # CHECK: :[[#@LINE]]:3: error: fixup value out of range
+  beqz $a0, far_distant_bz # CHECK: :[[#@LINE]]:3: error: fixup value out of range represented by 23 bit
 
   b unaligned # CHECK: :[[#@LINE]]:3: error: fixup value must be 4-byte aligned
 
Index: llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
===================================================================
--- llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
+++ llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
@@ -89,21 +89,24 @@
     return Value;
   case LoongArch::fixup_loongarch_b16: {
     if (!isInt<18>(Value))
-      Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
+      Ctx.reportError(Fixup.getLoc(),
+                      "fixup value out of range represented by 18 bit");
     if (Value % 4)
       Ctx.reportError(Fixup.getLoc(), "fixup value must be 4-byte aligned");
     return (Value >> 2) & 0xffff;
   }
   case LoongArch::fixup_loongarch_b21: {
     if (!isInt<23>(Value))
-      Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
+      Ctx.reportError(Fixup.getLoc(),
+                      "fixup value out of range represented by 23 bit");
     if (Value % 4)
       Ctx.reportError(Fixup.getLoc(), "fixup value must be 4-byte aligned");
     return ((Value & 0x3fffc) << 8) | ((Value >> 18) & 0x1f);
   }
   case LoongArch::fixup_loongarch_b26: {
     if (!isInt<28>(Value))
-      Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
+      Ctx.reportError(Fixup.getLoc(),
+                      "fixup value out of range represented by 28 bit");
     if (Value % 4)
       Ctx.reportError(Fixup.getLoc(), "fixup value must be 4-byte aligned");
     return ((Value & 0x3fffc) << 8) | ((Value >> 18) & 0x3ff);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136742.470723.patch
Type: text/x-patch
Size: 2544 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221026/6a9e6395/attachment.bin>


More information about the llvm-commits mailing list