From 5d0233bea22a103b5ecb5a9b5453f1206f2defe0 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Sat, 10 Dec 2016 10:16:13 +0000 Subject: [PATCH] [AVR] Support stores to undefined pointers This would previously trigger an assertion error in AVRISelDAGToDAG. llvm-svn: 289321 --- llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp | 3 ++- llvm/test/CodeGen/AVR/store-undef.ll | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/AVR/store-undef.ll diff --git a/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp b/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp index 098ee61b..9ef9874 100644 --- a/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp +++ b/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp @@ -328,7 +328,8 @@ template <> bool AVRDAGToDAGISel::select(SDNode *N) { SDValue BasePtr = ST->getBasePtr(); // Early exit when the base pointer is a frame index node or a constant. - if (isa(BasePtr) || isa(BasePtr)) { + if (isa(BasePtr) || isa(BasePtr) || + BasePtr.isUndef()) { return false; } diff --git a/llvm/test/CodeGen/AVR/store-undef.ll b/llvm/test/CodeGen/AVR/store-undef.ll new file mode 100644 index 0000000..58ea500 --- /dev/null +++ b/llvm/test/CodeGen/AVR/store-undef.ll @@ -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 +} -- 2.7.4