[PATCH] D66980: [Windows] Disable TrapUnreachable for Win64, add SEH_NoReturn

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 29 15:54:56 PDT 2019


rnk created this revision.
rnk added reviewers: hans, mstorsjo.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
rnk updated this revision to Diff 217993.
rnk added a comment.

- fix test


Users have complained llvm.trap produce two ud2 instructions on Win64,
one for the trap, and one for unreachable. This change fixes that.

TrapUnreachable was added and enabled for Win64 in r206684 (April 2014)
to avoid issues where the unwinder would disassemble forward from a
call's return address and go off the rails. Some of my experiments show
that the unwinder will sometimes use the unwind info from the next
function to unwind, if you arrange for the throwing call to end on a
16-byte aligned boundary. By trapping on unreachable, we ensured that
noreturn calls would always have some real instructions after the return
address, so the return address would be inside the bounds of the region
described by the unwind info.

Instead, this change inserts a new pseudo instruction, SEH_NoReturn,
which expands to an int3 if it happens to be the last instruction in the
current funclet after basic block layout. This approach is similar to
the approach we took with SEH_Epilogue, which expands to a nop if there
is a call immediately preceding the pseudo instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66980

Files:
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/WinEH/wineh-noret-cleanup.ll
  llvm/test/CodeGen/X86/br-fold.ll
  llvm/test/CodeGen/X86/catchpad-lifetime.ll
  llvm/test/CodeGen/X86/catchpad-regmask.ll
  llvm/test/CodeGen/X86/catchret-regmask.ll
  llvm/test/CodeGen/X86/empty-function.ll
  llvm/test/CodeGen/X86/funclet-layout.ll
  llvm/test/CodeGen/X86/noreturn-call-win64.ll
  llvm/test/CodeGen/X86/pr24374.ll
  llvm/test/CodeGen/X86/trap.ll
  llvm/test/CodeGen/X86/unreachable-trap.ll
  llvm/test/CodeGen/X86/win64_call_epi.ll
  llvm/test/CodeGen/X86/win64_eh.ll
  llvm/test/DebugInfo/COFF/local-variable-gap.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66980.217993.patch
Type: text/x-patch
Size: 18697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190829/c5b32940/attachment-0001.bin>


More information about the llvm-commits mailing list