[llvm] r345830 - [mips][micromips] Fix JmpLink to TargetExternalSymbol

Aleksandar Beserminji via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 1 06:57:54 PDT 2018


Author: abeserminji
Date: Thu Nov  1 06:57:54 2018
New Revision: 345830

URL: http://llvm.org/viewvc/llvm-project?rev=345830&view=rev
Log:
[mips][micromips] Fix JmpLink to TargetExternalSymbol

When matching MipsISD::JmpLink t9, TargetExternalSymbol:i32'...',
wrong JALR16_MM is selected. This patch adds missing pattern for
JmpLink, so that JAL instruction is selected.

Differential Revision: https://reviews.llvm.org/D53366

Added:
    llvm/trunk/test/CodeGen/Mips/micromips-target-external-symbol-reloc.ll
Modified:
    llvm/trunk/lib/Target/Mips/MicroMipsInstrInfo.td

Modified: llvm/trunk/lib/Target/Mips/MicroMipsInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MicroMipsInstrInfo.td?rev=345830&r1=345829&r2=345830&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MicroMipsInstrInfo.td (original)
+++ llvm/trunk/lib/Target/Mips/MicroMipsInstrInfo.td Thu Nov  1 06:57:54 2018
@@ -1271,6 +1271,8 @@ let AddedComplexity = 40 in
 def : MipsPat<(bswap GPR32:$rt), (ROTR_MM (WSBH_MM GPR32:$rt), 16)>,
       ISA_MICROMIPS;
 
+def : MipsPat<(MipsJmpLink (i32 texternalsym:$dst)),
+              (JAL_MM texternalsym:$dst)>, ISA_MICROMIPS32_NOT_MIPS32R6;
 def : MipsPat<(MipsTailCall (iPTR tglobaladdr:$dst)),
               (TAILCALL_MM tglobaladdr:$dst)>, ISA_MICROMIPS32_NOT_MIPS32R6;
 def : MipsPat<(MipsTailCall (iPTR texternalsym:$dst)),

Added: llvm/trunk/test/CodeGen/Mips/micromips-target-external-symbol-reloc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/micromips-target-external-symbol-reloc.ll?rev=345830&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/micromips-target-external-symbol-reloc.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/micromips-target-external-symbol-reloc.ll Thu Nov  1 06:57:54 2018
@@ -0,0 +1,13 @@
+; RUN: llc -mtriple=mips-mti-linux-gnu -mcpu=mips32r2 -mattr=+micromips -stop-after=expand-isel-pseudos < %s | FileCheck %s
+
+; CHECK: JAL_MM
+; CHECK-NOT: JALR16_MM
+
+define dso_local void @foo(i32* nocapture %ar) local_unnamed_addr {
+entry:
+  %0 = bitcast i32* %ar to i8*
+  tail call void @llvm.memset.p0i8.i32(i8* align 4 %0, i8 0, i32 100, i1 false)
+  ret void
+}
+
+declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1)




More information about the llvm-commits mailing list