[PATCH] D136317: Avoid inline optimization for unwind_phase2 and unwind_phase2_forced

xiongji90 via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 19:47:56 PDT 2022


xiongji90 added a comment.

In D136317#3881482 <https://reviews.llvm.org/D136317#3881482>, @MaskRay wrote:

> Can you add the stacktrace to the description?

Hi, @MaskRay 
Following is stack trace which current implementation assumes:
---------------------------|
unwind_phase2               
---------------------------|
_Unwind_RaiseException
---------------------------|
__cxa_throw
--------------------------|
user function frames...
--------------------------|

In unwind_phase2, we will go through stacks and count the number of stack frames which needs to be skipped. We initialize variable "framesWalked" to 1 in "unwind_phase2" and "unwind_phase2_forced", this is because these 2 functions have corresponding stack frame and also have corresponding records in CET shadow stack, so we need to remove CET shadow record for "unwind_phase2" and "unwind_phase2_forced" when unwinding normal stack. However, if "unwind_phase2" or "unwind_phase2_forced" are inlined, then there will be no corresponding stack frame and corresponding CET shadow stack record, the stack trace will turn to:

---------------------------|
_Unwind_RaiseException
---------------------------|
__cxa_throw
--------------------------|
user function frames...
--------------------------|

Under such circumstance, we need to initialize "framesWalked" to 0.  Although current implementation does work, we can't control whether compiler will optimize unwind_phase2 away in the future, so suggest to add "noinline" to guard.

Thanks very much.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136317/new/

https://reviews.llvm.org/D136317



More information about the llvm-commits mailing list