This is an archive of the discontinued LLVM Phabricator instance.

[SEH] Remove CATCHPAD SDNode and X86::EH_RESTORE MachineInstr
ClosedPublic

Authored by rnk on Jan 30 2020, 3:32 PM.

Details

Summary

The CATCHPAD node mostly existed to be selected into the EH_RESTORE
instruction, which sets the frame back up when 32-bit Windows exceptions
return to the parent function. However, creating this MachineInstr early
increases the risk that other passes will come along and insert
instructions that use the stack before ESP and EBP are restored. That
happened in PR44697.

Instead of representing these in the instruction stream early, delay it
until PEI. Mark the blocks where this needs to happen as EHPads, but not
funclet entry blocks. Passes after PEI have to be careful not to hoist
instructions that can use stack across frame setup instructions, so this
should be relatively reliable.

Fixes PR44697

Diff Detail

Event Timeline

rnk created this revision.Jan 30 2020, 3:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2020, 3:32 PM

Unit tests: fail. 62355 tests passed, 1 failed and 839 were skipped.

failed: libc++.std/containers/sequences/array/array_creation/to_array.fail.cpp

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

hans accepted this revision.Feb 3 2020, 6:02 AM

I noticed that AArch64 had a lowering for ISD::CATCHPAD before, but lowered just by deleting it?

Seems reasonable to me.

llvm/lib/Target/X86/X86FrameLowering.cpp
3225

This is the same comment as in the function below. Maybe it's not really necessary here?

This revision is now accepted and ready to land.Feb 3 2020, 6:02 AM
rnk marked an inline comment as done.Feb 4 2020, 3:18 PM

Thanks!

llvm/lib/Target/X86/X86FrameLowering.cpp
3225

I think I duplicated it because it explains the "funclets & 32-bit" condition, but I think this one is unnecessary.

This revision was automatically updated to reflect the committed changes.