[PATCH] D72075: [ARM] Use correct TRAP opcode for thumb in FastISel

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 2 03:41:37 PST 2020


dmgreen created this revision.
dmgreen added reviewers: efriedma, ostannard, SjoerdMeijer.
Herald added subscribers: hiraditya, kristof.beyls, dschuff.
Herald added a project: LLVM.
dmgreen added a reviewer: t.p.northover.

We were previously unconditionally using the ARM::TRAP opcode, even under Thumb. My understanding is that these are essentially the same thing (they both result in a trap under Thumb), but the ARM::TRAP opcode is marked as requiring IsARM, so it is more correct to use ARM::tTRAP.

The only test here just updates a case of the wrong code being used. The idea is to attempt to enable PREDICATE_VERIFIER for the arm target, which will test this kind of thing more thoroughly. There are some mulv5 vs mul and global ISel problems to sort out first though.


https://reviews.llvm.org/D72075

Files:
  llvm/lib/Target/ARM/ARMFastISel.cpp
  llvm/test/CodeGen/ARM/load_store_opt_clobber_cpsr.mir


Index: llvm/test/CodeGen/ARM/load_store_opt_clobber_cpsr.mir
===================================================================
--- llvm/test/CodeGen/ARM/load_store_opt_clobber_cpsr.mir
+++ llvm/test/CodeGen/ARM/load_store_opt_clobber_cpsr.mir
@@ -30,4 +30,4 @@
     renamable $r1 = tLDRi renamable $r4, 1, 14, $noreg :: (load 4)
   bb.2:
     liveins: $r4
-    TRAP
+    tTRAP
Index: llvm/lib/Target/ARM/ARMFastISel.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMFastISel.cpp
+++ llvm/lib/Target/ARM/ARMFastISel.cpp
@@ -2566,8 +2566,12 @@
     return SelectCall(&I, "memset");
   }
   case Intrinsic::trap: {
-    BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(
-      Subtarget->useNaClTrap() ? ARM::TRAPNaCl : ARM::TRAP));
+    unsigned Opcode;
+    if (Subtarget->isThumb())
+      Opcode = ARM::tTRAP;
+    else
+      Opcode = Subtarget->useNaClTrap() ? ARM::TRAPNaCl : ARM::TRAP;
+    BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opcode));
     return true;
   }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72075.235845.patch
Type: text/x-patch
Size: 1052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200102/e6cf7cbc/attachment.bin>


More information about the llvm-commits mailing list