[PATCH] D36991: [x86] [MC] fixed no error diagnostic for out-of-range jrcxz/jecxz/jcxz (PR24072)

Konstantin Belochapka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 16:55:05 PDT 2017


kbelochapka created this revision.

Fixed no diagnostic message problem for out of range fixup value for loop/loope/loopne/jcxz/jecxz/jrcxz instructions.


https://reviews.llvm.org/D36991

Files:
  lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  test/MC/X86/x86-jcxz-loop-fixup.s


Index: test/MC/X86/x86-jcxz-loop-fixup.s
===================================================================
--- test/MC/X86/x86-jcxz-loop-fixup.s
+++ test/MC/X86/x86-jcxz-loop-fixup.s
@@ -0,0 +1,29 @@
+# RUN: not llvm-mc -filetype=obj -triple=x86_64-linux-gnu %s 2>&1 | FileCheck %s
+
+       .balign 256
+label00:
+// CHECK: Value 509 does not fit in the Fixup field
+	jecxz   label01
+// CHECK: Value 507 does not fit in the Fixup field
+	jrcxz   label01
+// CHECK: Value 505 does not fit in the Fixup field
+	loop	label01
+// CHECK: Value 503 does not fit in the Fixup field
+	loope	label01
+// CHECK: Value 501 does not fit in the Fixup field
+	loopne	label01
+        .balign 512
+label01:
+// CHECK: Value -515 does not fit in the Fixup field
+	jecxz   label00
+// CHECK: Value -517 does not fit in the Fixup field
+	jrcxz   label00
+// CHECK: Value -519 does not fit in the Fixup field
+	loop	label00
+// CHECK: Value -521 does not fit in the Fixup field
+	loope	label00
+// CHECK: Value -523 does not fit in the Fixup field
+	loopne	label00
+
+
+
Index: lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
===================================================================
--- lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -13,6 +13,8 @@
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/BinaryFormat/MachO.h"
 #include "llvm/MC/MCAsmBackend.h"
+#include "llvm/MC/MCAssembler.h"
+#include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCELFObjectWriter.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCFixupKindInfo.h"
@@ -119,8 +121,11 @@
     // Specifically ignore overflow/underflow as long as the leakage is
     // limited to the lower bits. This is to remain compatible with
     // other assemblers.
-    assert(isIntN(Size * 8 + 1, Value) &&
-           "Value does not fit in the Fixup field");
+    if (!isIntN((Size * 8) - 1, Value)) {
+      Asm.getContext().reportError(Fixup.getLoc(),
+                                   "Value " + Twine(int64_t(Value)) +
+                                       " does not fit in the Fixup field");
+    }
 
     for (unsigned i = 0; i != Size; ++i)
       Data[Fixup.getOffset() + i] = uint8_t(Value >> (i * 8));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36991.112091.patch
Type: text/x-patch
Size: 2221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170821/a44bb021/attachment.bin>


More information about the llvm-commits mailing list