[AVR] Support stores to undefined pointers
authorDylan McKay <dylanmckay34@gmail.com>
Sat, 10 Dec 2016 10:16:13 +0000 (10:16 +0000)
committerDylan McKay <dylanmckay34@gmail.com>
Sat, 10 Dec 2016 10:16:13 +0000 (10:16 +0000)
This would previously trigger an assertion error in AVRISelDAGToDAG.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289321 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AVR/AVRISelDAGToDAG.cpp
test/CodeGen/AVR/store-undef.ll [new file with mode: 0644]

index 098ee61b738dab8f1740f75691c3a772640c4da7..9ef98749cdccbd693c19969d9b8f8f7c8a1e416f 100644 (file)
@@ -328,7 +328,8 @@ template <> bool AVRDAGToDAGISel::select<ISD::STORE>(SDNode *N) {
   SDValue BasePtr = ST->getBasePtr();
 
   // Early exit when the base pointer is a frame index node or a constant.
-  if (isa<FrameIndexSDNode>(BasePtr) || isa<ConstantSDNode>(BasePtr)) {
+  if (isa<FrameIndexSDNode>(BasePtr) || isa<ConstantSDNode>(BasePtr) ||
+      BasePtr.isUndef()) {
     return false;
   }
 
diff --git a/test/CodeGen/AVR/store-undef.ll b/test/CodeGen/AVR/store-undef.ll
new file mode 100644 (file)
index 0000000..58ea500
--- /dev/null
@@ -0,0 +1,13 @@
+; RUN: llc < %s -mattr=avr6 | FileCheck %s
+
+; This test checks that we can successfully lower a store
+; to an undefined pointer.
+
+; CHECK-LABEL: foo
+define void @foo() {
+
+  ; CHECK:      ldi [[SRC:r[0-9]+]], 0
+  ; CHECK-NEXT: st [[PTRREG:X|Y|Z]], [[SRC]]
+  store i8 0, i8* undef, align 4
+  ret void
+}