[PATCH] D81908: [MIPS] Fix incorrect relocations of instruction

hev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 16 05:31:53 PDT 2020


hev updated this revision to Diff 271062.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81908/new/

https://reviews.llvm.org/D81908

Files:
  llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
  llvm/test/MC/Mips/reloc-implicit-constraints-error.s


Index: llvm/test/MC/Mips/reloc-implicit-constraints-error.s
===================================================================
--- /dev/null
+++ llvm/test/MC/Mips/reloc-implicit-constraints-error.s
@@ -0,0 +1,15 @@
+# RUN: not llvm-mc -triple mips-unknown-linux-gnu -filetype obj -o /dev/null %s 2>%t1
+# RUN: FileCheck %s < %t1
+
+# RUN: not llvm-mc -triple mips64-unknown-linux-gnu -filetype obj -o /dev/null %s 2>%t1
+# RUN: FileCheck %s < %t1
+
+# Check that implicit constraints error
+
+  ori  $4, $4, start            # CHECK: [[@LINE]]:{{[0-9]+}}: error: should use explicit constraints
+  ori  $4, $4, (start - .)      # CHECK: [[@LINE]]:{{[0-9]+}}: error: should use explicit constraints
+
+  addiu  $4, $4, start          # CHECK: [[@LINE]]:{{[0-9]+}}: error: should use explicit constraints
+  addiu  $4, $4, (start - .)    # CHECK: [[@LINE]]:{{[0-9]+}}: error: should use explicit constraints
+
+start:
Index: llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
===================================================================
--- llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
+++ llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
@@ -724,19 +724,7 @@
   }
 
   if (Kind == MCExpr::SymbolRef) {
-    Mips::Fixups FixupKind = Mips::Fixups(0);
-
-    switch(cast<MCSymbolRefExpr>(Expr)->getKind()) {
-    default: llvm_unreachable("Unknown fixup kind!");
-      break;
-    case MCSymbolRefExpr::VK_None:
-      // FIXME: This is ok for O32/N32 but not N64.
-      FixupKind = Mips::fixup_Mips_32;
-      break;
-    } // switch
-
-    Fixups.push_back(MCFixup::create(0, Expr, MCFixupKind(FixupKind)));
-    return 0;
+    Ctx.reportError(Expr->getLoc(), "should use explicit constraints");
   }
   return 0;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81908.271062.patch
Type: text/x-patch
Size: 1748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200616/62027867/attachment.bin>


More information about the llvm-commits mailing list