-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update libunwind to v1.6.2 #62092
Update libunwind to v1.6.2 #62092
Conversation
2a74cc1
to
4858d37
Compare
4858d37
to
b3bd800
Compare
@janvorli, this is ready for review, could you please take a look? libunwind-version.txt has the updated info, how this copy currently differs from upstream. Thanks! |
b3bd800
to
abf6037
Compare
a097628
to
cf16424
Compare
cc @mikem8361 |
@janvorli, @jkotas, this is ready from my side, please let me know if there is any more feedback. We could run the outerloop leg against this PR to make sure alpine arm64 library tests haven't regressed. Unfortunately the passing rate of the so I'm not sure which specific tests we will be looking at to detect any regression.. |
"nop\n" \ | ||
".code 32\n" \ | ||
"mov r0, #0\n" \ | ||
"stmia %[base], {r0-r14}\n" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now missing my changes that added storing the floating point registers. In both the thumb and non-thumb code. For the #else
branch, just adding my two lines after the stmia
should be enough. For the #if
branch, we would need to make sure that the PC stored by the stmia
matches the new semantics of the code from the libunwind repo, that means that it points after the nop
. It seems that the easiest is to store the floating point registers first and then the floating point ones. A simple approach would be to add the following before the stmia
:
"adds %[base], #64\n" \
"vstmia %[base], {d0-d15}\n" \
"subs %[base], #64\n" \
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janvorli, thanks, is it the correct patch:
diff --git a/src/coreclr/pal/src/libunwind/include/libunwind-arm.h b/src/coreclr/pal/src/libunwind/include/libunwind-arm.h
index 9108dd9d9a3..c5c2b3072ac 100644
--- a/src/coreclr/pal/src/libunwind/include/libunwind-arm.h
+++ b/src/coreclr/pal/src/libunwind/include/libunwind-arm.h
@@ -280,6 +280,9 @@ unw_tdep_context_t;
unsigned long *unw_base = unw_ctx->regs; \
__asm__ __volatile__ ( \
"mov r0, #0\n" \
+ "adds %[base], #64\n" \
+ "vstmia %[base], {d0-d15}\n" \
+ "subs %[base], #64\n" \
"stmia %[base], {r0-r15}\n" \
"nop\n" /* align return address to value stored by stmia */ \
: [r0] "=r" (r0) : [base] "r" (unw_base) : "memory"); \
@@ -295,6 +298,9 @@ unw_tdep_context_t;
"nop\n" \
".code 32\n" \
"mov r0, #0\n" \
+ "adds %[base], #64\n" \
+ "vstmia %[base], {d0-d15}\n" \
+ "subs %[base], #64\n" \
"stmia %[base], {r0-r14}\n" \
"adr r0, ret%=+1\n" \
"str r0, [%[base], #60]\n" \
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that it correct. However the thumb branch (the #else one) can be simpler, since the PC is computed and stored separately there. So we can use the following form, saving one subs
.
@@ -295,6 +298,9 @@ unw_tdep_context_t;
"nop\n" \
".code 32\n" \
"mov r0, #0\n" \
"stmia %[base], {r0-r14}\n" \
"adr r0, ret%=+1\n" \
"str r0, [%[base], #60]\n"
+ "adds %[base], #64\n"
+ "vstmia %[base], {d0-d15}\n" \
"orr r0, pc, #1\n" \
"bx r0\n"
We could possibly get rid of the subs in the #if
branch too if we made the writes backwards (instead of stmia
we would use stmda
), but I think it is not worth making the code less readable that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied and rebased. All arm changes are in a single commit: 0ca7809.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better, I think you can directly replace the nop
with vstmia %[base], {d0-d15}\n
without needing to adjust the base at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janvorli, can we add a test case in Pri0 category for regular PRs that will:
- make use of arm32 fp registers and hit this path
- fail without applying your patch
I am not sure if it is as trivial as changing this test project\s property from 1 to 0
<CLRTestPriority>1</CLRTestPriority> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is that I think we cannot enforce using non-volatile floating point registers (D8..D15) in the jitted code. Using volatile ones doesn't cause issues, as we don't need to unwind it. Also, the register needs to be modified by the native code we unwind from to cause harm. Managed code uses the windows style unwinder, so it works unrelated to this change.
We were hitting the issue in one of the tests with JIT stress enabled - the JIT stress resulted in using the D8 register. I think that might be just a coincidence though. I believe we run tests with jit stress enabled nightly or on some regular basis, so I'll check if that test still reproduces the problem so that we have some coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, though you may also now need to update the register constraint to let the compiler know that you are now clobbering that register
@vtjnash good point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@am11 I have verified that this update works with the TestConvertFromIntegral test by manually stepping through the unwinder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janvorli, thank you for all the help. :)
33dcfd3
to
275c845
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
275c845
to
e621e21
Compare
e621e21
to
bb4af17
Compare
Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
bb4af17
to
22e93a0
Compare
Co-authored-by: Jan Vorlicek <jan.vorlicek@volny.cz>
All changes upstream since v1.5-rc2 libunwind/libunwind@v1.5-rc2...v1.6.2.
Method:
src/coreclr/pal/src/libunwind/libunwind-version.txt
.