From f77c03a8599ca354393292bb6c918ea8dab6a21d Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Fri, 24 Feb 2012 17:53:59 +0000 Subject: [PATCH] Don't crash when a glue node contains an internal CopyToReg This is necessary to support the existing ppc lowering code for indirect calls. Fixes PR12071. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151373 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/InstrEmitter.cpp | 3 +++ test/CodeGen/PowerPC/ppc64-ind-call.ll | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 test/CodeGen/PowerPC/ppc64-ind-call.ll diff --git a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp index 3f4f9e26254..1467d887789 100644 --- a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp +++ b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp @@ -766,6 +766,9 @@ EmitMachineNode(SDNode *Node, bool IsClone, bool IsCloned, if (F->getOpcode() == ISD::CopyFromReg) { UsedRegs.push_back(cast(F->getOperand(1))->getReg()); continue; + } else if (F->getOpcode() == ISD::CopyToReg) { + // Skip CopyToReg nodes that are internal to the glue chain. + continue; } // Collect declared implicit uses. const MCInstrDesc &MCID = TII->get(F->getMachineOpcode()); diff --git a/test/CodeGen/PowerPC/ppc64-ind-call.ll b/test/CodeGen/PowerPC/ppc64-ind-call.ll new file mode 100644 index 00000000000..f2d7cb489ed --- /dev/null +++ b/test/CodeGen/PowerPC/ppc64-ind-call.ll @@ -0,0 +1,12 @@ +; RUN: llc < %s -march=ppc64 | FileCheck %s +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64" +target triple = "powerpc64-unknown-linux-gnu" + +define void @test1() { +entry: + %call.i75 = call zeroext i8 undef(i8* undef, i8 zeroext 10) + unreachable +} + +; CHECK: @test1 +