[llvm-commits] [llvm] r165617 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/2012-10-04-LDRB_POST_IMM-Crash.ll

Stepan Dyatkovskiy stpworld at narod.ru
Wed Oct 10 04:43:40 PDT 2012


Author: dyatkovskiy
Date: Wed Oct 10 06:43:40 2012
New Revision: 165617

URL: http://llvm.org/viewvc/llvm-project?rev=165617&view=rev
Log:
Fix for LDRB instruction:
SDNode for LDRB_POST_IMM is invalid: number of registers added to SDNode fewer
that described in .td.

7 ops is needed, but SDNode with only 6 is created.

In more details:
In ARMInstrInfo.td, in multiclass AI2_ldridx, in definition _POST_IMM, offset
operand is defined as am2offset_imm. am2offset_imm is complex parameter type,
and actually it consists from dummy register and imm itself. As I understood
trick with dummy reg was made for AsmParser. In ARMISelLowering.cpp, this dummy
register was not added to SDNode, and it cause crash in Peephole Optimizer pass.

The problem fixed by setting up additional dummy reg when emitting
LDRB_POST_IMM instruction.


Added:
    llvm/trunk/test/CodeGen/ARM/2012-10-04-LDRB_POST_IMM-Crash.ll
Modified:
    llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=165617&r1=165616&r2=165617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Oct 10 06:43:40 2012
@@ -6418,7 +6418,8 @@
       } else {
         AddDefaultPred(BuildMI(*BB, MI, dl,
           TII->get(ldrOpc),scratch)
-          .addReg(srcOut, RegState::Define).addReg(srcIn).addImm(1));
+          .addReg(srcOut, RegState::Define).addReg(srcIn)
+          .addReg(0).addImm(1));
 
         AddDefaultPred(BuildMI(*BB, MI, dl, TII->get(strOpc), destOut)
           .addReg(scratch).addReg(destIn)

Added: llvm/trunk/test/CodeGen/ARM/2012-10-04-LDRB_POST_IMM-Crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2012-10-04-LDRB_POST_IMM-Crash.ll?rev=165617&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/2012-10-04-LDRB_POST_IMM-Crash.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/2012-10-04-LDRB_POST_IMM-Crash.ll Wed Oct 10 06:43:40 2012
@@ -0,0 +1,23 @@
+; RUN: llc < %s -mtriple=armv7-none-linux-gnueabi | FileCheck %s
+; Check that LDRB_POST_IMM instruction emitted properly.
+
+%my_struct_t = type { double, double, double }
+ at main.val = private unnamed_addr constant %my_struct_t { double 1.0, double 2.0, double 3.0 }, align 8
+
+declare void @f(i32 %n1, %my_struct_t* byval %val);
+
+
+; CHECK: main:
+define i32 @main() nounwind {
+entry:
+  %val = alloca %my_struct_t, align 8
+  %0 = bitcast %my_struct_t* %val to i8*
+
+; CHECK: ldrb	{{(r[0-9]+)}}, {{(\[r[0-9]+\])}}, #1
+  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* bitcast (%my_struct_t* @main.val to i8*), i32 24, i32 8, i1 false)
+
+  call void @f(i32 555, %my_struct_t* byval %val)
+  ret i32 0
+}
+
+declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind





More information about the llvm-commits mailing list