From 4fc5f3c02e57136c7c4055bd2f83a56bb79d37e5 Mon Sep 17 00:00:00 2001 From: Sam Parker Date: Tue, 11 Apr 2017 08:43:32 +0000 Subject: [PATCH] [SelectionDAG] Check CALLSEQ_BEGIN nodes in DelayForLiveRegs A fix for the bug reported in PR30911. The issue arises when multiple CALLSEQ_BEGIN nodes are unscheduled as the last node to be unscheduled will gain access to the CallResource register. But when a node is being picked, only CALLSEQ_END nodes are checked against the CallResource and have their chains evaluated. This then means that other CALLSEQ_BEGIN nodes can be scheduled before the existing call sequence has been finalised. This patch adds a check against the FrameSetup nodes in DelayForLiveRegs to prevent this from happening. Differential Revision: https://reviews.llvm.org/D31536 llvm-svn: 299926 --- .../SelectionDAG/ScheduleDAGRRList.cpp | 3 +- .../test/CodeGen/ARM/unschedule-first-call.ll | 136 ++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/ARM/unschedule-first-call.ll diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp index a0e2fb62f1de..2018b011e14f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -1305,7 +1305,8 @@ DelayForLiveRegsBottomUp(SUnit *SU, SmallVectorImpl &LRegs) { // If we're in the middle of scheduling a call, don't begin scheduling // another call. Also, don't allow any physical registers to be live across // the call. - if (Node->getMachineOpcode() == (unsigned)TII->getCallFrameDestroyOpcode()) { + if ((Node->getMachineOpcode() == TII->getCallFrameDestroyOpcode()) || + (Node->getMachineOpcode() == TII->getCallFrameSetupOpcode())) { // Check the special calling-sequence resource. unsigned CallResource = TRI->getNumRegs(); if (LiveRegDefs[CallResource]) { diff --git a/llvm/test/CodeGen/ARM/unschedule-first-call.ll b/llvm/test/CodeGen/ARM/unschedule-first-call.ll new file mode 100644 index 000000000000..4a218afcc5e1 --- /dev/null +++ b/llvm/test/CodeGen/ARM/unschedule-first-call.ll @@ -0,0 +1,136 @@ +; RUN: llc < %s +; PR30911 + +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv6kz--linux-gnueabihf" + +; Function Attrs: nounwind +define void @dradbg(i32, i32, float*, float*, float*, float*, float*) #0 { + br i1 undef, label %.critedge, label %8 + +.critedge: ; preds = %7 + %.mux2 = select i1 undef, i1 undef, i1 true + br label %8 + +;