summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEli Friedman <efriedma@quicinc.com>2019-02-28 20:38:45 +0000
committerEli Friedman <efriedma@quicinc.com>2019-02-28 20:38:45 +0000
commitd19a7060c6bd50f6fa1a189c3bb3d1cc655fd73f (patch)
treef0c1a0286b1487bc1a32bb928e647e08e1e1074d /llvm/lib
parente09f8ecac9a942ed6f82990f025c3f5d4d98782d (diff)
downloadbcm5719-llvm-d19a7060c6bd50f6fa1a189c3bb3d1cc655fd73f.tar.gz
bcm5719-llvm-d19a7060c6bd50f6fa1a189c3bb3d1cc655fd73f.zip
[AArch64] [Windows] Don't skip constructing UnwindHelp.
In certain cases, the first non-frame-setup instruction in a function is a branch. For example, it could be a cbz on an argument. Make sure we correctly allocate the UnwindHelp, and find an appropriate register to use to initialize it. Fixes https://bugs.llvm.org/show_bug.cgi?id=40184 Differential Revision: https://reviews.llvm.org/D58752 llvm-svn: 355136
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/AArch64/AArch64FrameLowering.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
index 446e1928d26..597b25cba1c 100644
--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -2142,9 +2142,6 @@ void AArch64FrameLowering::processFunctionBeforeFrameFinalized(
while (MBBI != MBB.end() && MBBI->getFlag(MachineInstr::FrameSetup))
++MBBI;
- if (MBBI->isTerminator())
- return;
-
// Create an UnwindHelp object.
int UnwindHelpFI =
MFI.CreateStackObject(/*size*/8, /*alignment*/16, false);
@@ -2152,8 +2149,10 @@ void AArch64FrameLowering::processFunctionBeforeFrameFinalized(
// We need to store -2 into the UnwindHelp object at the start of the
// function.
DebugLoc DL;
- RS->enterBasicBlock(MBB);
- unsigned DstReg = RS->scavengeRegister(&AArch64::GPR64RegClass, MBBI, 0);
+ RS->enterBasicBlockEnd(MBB);
+ RS->backward(std::prev(MBBI));
+ unsigned DstReg = RS->FindUnusedReg(&AArch64::GPR64commonRegClass);
+ assert(DstReg && "There must be a free register after frame setup");
BuildMI(MBB, MBBI, DL, TII.get(AArch64::MOVi64imm), DstReg).addImm(-2);
BuildMI(MBB, MBBI, DL, TII.get(AArch64::STURXi))
.addReg(DstReg, getKillRegState(true))
OpenPOWER on IntegriCloud