[PATCH] D77982: [Windows SEH] Fix the frame-ptr of a nested-filter within a _finally

Ten Tzen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 12 16:01:37 PDT 2020


tentzen created this revision.
tentzen added reviewers: rnk, eli.friedman, JosephTremoulet, asmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change fixed a SEH bug (exposed by test58 & test61 in MSVC test xcpt4u.c);
when an Except-filter is located inside a finally, the frame-pointer generated today via intrinsic @llvm.eh.recoverfp is the frame-pointer of the immediate parent  _finally, not the frame-ptr of outermost host function.

The fix is to retrieve the Establisher's frame-pointer that was previously saved in parent's frame.  
The prolog of a filter inside a _finally should be like:

  %0 = call i8* @llvm.eh.recoverfp(i8* bitcast (@"?fin$0 at 0@main@@"), i8* %frame_pointer)
  %1 = call i8* @llvm.localrecover(i8* bitcast (@"?fin$0 at 0@main@@"), i8* %0, i32 0)
  %2 = bitcast i8* %1 to i8**
  %3 = load i8*, i8** %2, align 8


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77982

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/windows-seh-filter-inFinally.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77982.256890.patch
Type: text/x-patch
Size: 4285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200412/840d333d/attachment.bin>


More information about the cfe-commits mailing list