diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp --- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp +++ b/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); diff --git a/llvm/test/MC/LoongArch/Relocations/fixups-diagnostics.s b/llvm/test/MC/LoongArch/Relocations/fixups-diagnostics.s --- a/llvm/test/MC/LoongArch/Relocations/fixups-diagnostics.s +++ b/llvm/test/MC/LoongArch/Relocations/fixups-diagnostics.s @@ -9,12 +9,12 @@ .byte 0 .byte 0 - beq $a0, $a1, out_of_range_b16 # CHECK: :[[#@LINE]]:3: error: fixup value out of range + beq $a0, $a1, out_of_range_b18 # CHECK: :[[#@LINE]]:3: error: fixup value out of range range represented by 18 bit .space 1<<18 -out_of_range_b16: - beqz $a0, out_of_range_b21 # CHECK: :[[#@LINE]]:3: error: fixup value out of range +out_of_range_b18: + beqz $a0, out_of_range_b23 # CHECK: :[[#@LINE]]:3: error: fixup value out of range range represented by 23 bit .space 1<<23 -out_of_range_b21: - b out_of_range_b26 # CHECK: :[[#@LINE]]:3: error: fixup value out of range +out_of_range_b23: + b out_of_range_b28 # CHECK: :[[#@LINE]]:3: error: fixup value out of range represented by 28 bit .space 1<<28 -out_of_range_b26: +out_of_range_b28: