From 975726345cb4914152fd7d07d92d41dcfd921503 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sat, 20 Sep 2014 00:10:47 +0000 Subject: [PATCH] Fix crash with an insertvalue that produces an empty object. llvm-svn: 218171 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 6 ++++++ llvm/test/CodeGen/Generic/empty-insertvalue.ll | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 llvm/test/CodeGen/Generic/empty-insertvalue.ll diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 6d302f98f55f..6a8cd2eb3b16 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -3307,6 +3307,12 @@ void SelectionDAGBuilder::visitInsertValue(const InsertValueInst &I) { unsigned NumValValues = ValValueVTs.size(); SmallVector Values(NumAggValues); + // Ignore an insertvalue that produces an empty object + if (!NumAggValues) { + setValue(&I, DAG.getUNDEF(MVT(MVT::Other))); + return; + } + SDValue Agg = getValue(Op0); unsigned i = 0; // Copy the beginning value(s) from the original aggregate. diff --git a/llvm/test/CodeGen/Generic/empty-insertvalue.ll b/llvm/test/CodeGen/Generic/empty-insertvalue.ll new file mode 100644 index 000000000000..e4cc27c2ffcf --- /dev/null +++ b/llvm/test/CodeGen/Generic/empty-insertvalue.ll @@ -0,0 +1,7 @@ +; RUN: llc < %s + +define void @f() { +entry: + %0 = insertvalue { [0 x { i8*, i8* }], [0 x { i8*, i64 }] } undef, [0 x { i8*, i8* }] undef, 0 + ret void +}