diff options
author | Daniel Paoliello <danpao@microsoft.com> | 2025-06-16 15:06:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-16 15:06:41 -0700 |
commit | 2488f26d15e7e12aef9ead3fcb2d1b6da51812fb (patch) | |
tree | 3418716488ee10dc45aaa61e4e4f5bd517057f7f /llvm/lib/IR/Module.cpp | |
parent | 4bcf9732c7361b3ea5208ced592245e0302fc7a2 (diff) | |
download | llvm-2488f26d15e7e12aef9ead3fcb2d1b6da51812fb.zip llvm-2488f26d15e7e12aef9ead3fcb2d1b6da51812fb.tar.gz llvm-2488f26d15e7e12aef9ead3fcb2d1b6da51812fb.tar.bz2 |
[win][x64] Unwind v2 3/n: Add support for requiring unwind v2 to be used (equivalent to MSVC's /d2epilogunwindrequirev2) (#143577)
#129142 added support for emitting Windows x64 unwind v2 information,
but it was "best effort". If any function didn't follow the requirements
for v2 it was silently downgraded to v1.
There are some parts of Windows (specifically kernel-mode code running
on Xbox) that require v2, hence we need the ability to fail the
compilation if v2 can't be used.
This change also adds a heuristic to check if there might be too many
unwind codes, it's currently conservative (i.e., assumes that certain
prolog instructions will use the maximum number of unwind codes).
Future work: attempting to chain unwind info across multiple tables if
there are too many unwind codes due to epilogs and adding a heuristic to
detect if an epilog will be too far from the end of the function.
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r-- | llvm/lib/IR/Module.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index 37f4a72..2d31481 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -917,3 +917,10 @@ StringRef Module::getTargetABIFromMD() { TargetABI = TargetABIMD->getString(); return TargetABI; } + +WinX64EHUnwindV2Mode Module::getWinX64EHUnwindV2Mode() const { + Metadata *MD = getModuleFlag("winx64-eh-unwindv2"); + if (auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(MD)) + return static_cast<WinX64EHUnwindV2Mode>(CI->getZExtValue()); + return WinX64EHUnwindV2Mode::Disabled; +} |