[PATCH] D75712: Avoid emitting unreachable SP adjustments after `throw`

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 5 15:53:48 PST 2020


rnk created this revision.
rnk added a reviewer: hans.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

In 172eee9c, we tried to avoid these by modelling the callee as
internally resetting the stack pointer.

However, for the majority of functions with reserved stack frames, this
would lead LLVM to emit extra SP adjustments to undo the callee's
internal adjustment. This lead us to fix the problem further on down the
pipeline in eliminateCallFramePseudoInstr. In 5b79e603d3b7a2994, I added
use a heuristic to try to detect when the adjustment would be
unreachable.

This heuristic is imperfect, and when exception handling is involved, it
fails to fire. The new test is an example of this. Simply throwing an
exception with an active cleanup emits dead SP adjustments after the
throw. Not only are they dead, but if they were executed, they would be
incorrect, so they are confusing.

This change essentially reverts 172eee9c and makes the 5b79e603d3b7a2994
heuristic responsible for preventing unreachable stack adjustments. This
means we may emit unreachable stack adjustments for functions using EH
with unreserved call frames, but that is not very many these days. Back
in 2016 when this change was added, we were focused on 32-bit, which we
observed to have fewer reserved frames.

Fixes PR45064


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75712

Files:
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/noreturn-call-win64.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75712.248619.patch
Type: text/x-patch
Size: 4861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200305/51b4a441/attachment.bin>


More information about the llvm-commits mailing list