From 55a4b6700f61f5a51a32e652368503b7583b971a Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 9 Jul 2017 16:01:04 +0000 Subject: Handle ConstantExpr correctly in SelectionDAGBuilder This change fixes a bug in SelectionDAGBuilder::visitInsertValue and SelectionDAGBuilder::visitExtractValue where constant expressions (InsertValueConstantExpr and ExtractValueConstantExpr) would be treated as non-constant instructions (InsertValueInst and ExtractValueInst). This bug resulted in an incorrect memory access, which manifested as an assertion failure in SDValue::SDValue. Fixes PR#33094. Submitted on behalf of @Praetonus (Benoit Vey) Differential Revision: https://reviews.llvm.org/D34538 llvm-svn: 307502 --- llvm/test/CodeGen/Generic/pr33094.ll | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 llvm/test/CodeGen/Generic/pr33094.ll (limited to 'llvm/test') diff --git a/llvm/test/CodeGen/Generic/pr33094.ll b/llvm/test/CodeGen/Generic/pr33094.ll new file mode 100644 index 00000000000..afa464f63f6 --- /dev/null +++ b/llvm/test/CodeGen/Generic/pr33094.ll @@ -0,0 +1,18 @@ +; RUN: llc < %s + +; PR33094 +; Make sure that a constant extractvalue doesn't cause a crash in +; SelectionDAGBuilder::visitExtractValue. + +%A = type {} +%B = type {} +%Tuple = type { i64 } + +@A_Inst = global %A zeroinitializer +@B_Inst = global %B zeroinitializer + +define i64 @foo() { + ret i64 extractvalue (%Tuple select (i1 icmp eq + (%B* bitcast (%A* @A_Inst to %B*), %B* @B_Inst), + %Tuple { i64 33 }, %Tuple { i64 42 }), 0) +} -- cgit v1.2.3