[PATCH] D14518: [ARM] Handle t2ADDri in ARMAsmPrinter::EmitUnwindingInstruction

Akira Hatanaka via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 9 15:31:34 PST 2015


ahatanak created this revision.
ahatanak added a reviewer: t.p.northover.
ahatanak added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.

This fixes a bug in ARMAsmPrinter::EmitUnwindingInstruction where llvm_unreachable was reached because t2ADDri wasn't handled.

It looks like this crash could also have been avoided if the function checked MAI->getExceptionHandlingType() (and returned early), but it looks like the case clause for t2ADDri should be added regardless of that.

http://reviews.llvm.org/D14518

Files:
  lib/Target/ARM/ARMAsmPrinter.cpp
  test/CodeGen/Thumb2/emit-unwinding.ll

Index: test/CodeGen/Thumb2/emit-unwinding.ll
===================================================================
--- /dev/null
+++ test/CodeGen/Thumb2/emit-unwinding.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple thumbv7em-apple-unknown-eabi-macho %s -o - -O0 -disable-fp-elim | FileCheck %s
+
+; CHECK: add.w r11, sp, #{{[1-9]+}}
+
+define i32 @foo1(i32 %n) {
+entry:
+  %n.addr = alloca i32, align 4
+  %a1 = alloca [256 x i32], align 4
+  store i32 %n, i32* %n.addr, align 4
+  %arraydecay = getelementptr inbounds [256 x i32], [256 x i32]* %a1, i32 0, i32 0
+  call void @foo2(i32* %arraydecay)
+  call void asm sideeffect "", "~{r4}"() #2
+  %0 = load i32, i32* %n.addr, align 4
+  %arrayidx = getelementptr inbounds [256 x i32], [256 x i32]* %a1, i32 0, i32 %0
+  %1 = load i32, i32* %arrayidx, align 4
+  %arrayidx1 = getelementptr inbounds [256 x i32], [256 x i32]* %a1, i32 0, i32 1
+  %2 = load i32, i32* %arrayidx1, align 4
+  %add = add nsw i32 %1, %2
+  ret i32 %add
+}
+
+declare void @foo2(i32*)
Index: lib/Target/ARM/ARMAsmPrinter.cpp
===================================================================
--- lib/Target/ARM/ARMAsmPrinter.cpp
+++ lib/Target/ARM/ARMAsmPrinter.cpp
@@ -1125,6 +1125,7 @@
         Offset = 0;
         break;
       case ARM::ADDri:
+      case ARM::t2ADDri:
         Offset = -MI->getOperand(2).getImm();
         break;
       case ARM::SUBri:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14518.39760.patch
Type: text/x-patch
Size: 1383 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151109/24be6771/attachment.bin>


More information about the llvm-commits mailing list