-
Notifications
You must be signed in to change notification settings - Fork 10.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
[PowerPC] Handle CALL_RM like CALL for 32-bit ELF #72758
base: main
Are you sure you want to change the base?
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
If a function call has the strictfp attribute, its opcode changes from CALL to CALL_RM. If the call uses the secure PLT for 32-bit ELF, then it must getGlobalBaseReg() to set r30.
d497ab3
to
b34f3c3
Compare
Handle CALL_RM like CALL for 32-bit ELF. If a function call has the strictfp attribute, its opcode changes from CALL to CALL_RM. If a call uses the secure PLT, then it must getGlobalBaseReg() to set r30. After I rebuilt xenocara/lib/pixman with this change, Xorg stopped crashing on my macppc. pixman uses cc -ftrapping-math which puts strictfp on each function call. llvm/llvm-project#72758 ok jca@ tobhe@ deraadt@
Ping. |
Ping. |
@@ -0,0 +1,21 @@ | |||
; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -mattr=+secure-plt -relocation-model=pic | FileCheck %s |
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.
Can we use auto generate script for it?
@kernigh Ping. |
@@ -5475,7 +5475,8 @@ void PPCDAGToDAGISel::Select(SDNode *N) { | |||
// generate secure plt code for TLS symbols. | |||
getGlobalBaseReg(); | |||
} break; | |||
case PPCISD::CALL: { | |||
case PPCISD::CALL: | |||
case PPCISD::CALL_RM: { |
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.
Are your targeting this for SPE? SPE should have no floating point instructions? So round mode should not be a concern? For SPE, we may stop generate CALL_RM where it is generated. Note that CALL_RM performs worse than normal CALL even after instruction selection. They are selected to different instructions.
If for other PPC32 targets, the fix looks reasonable to me.
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.
Are your targeting this for SPE?
This is not for SPE.
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 as long as @ecnelises's comment about the LIT case is addressed.
Handle CALL_RM like CALL for 32-bit ELF. If a function call has the strictfp attribute, its opcode changes from CALL to CALL_RM. If a call uses the secure PLT, then it must getGlobalBaseReg() to set r30. After I rebuilt xenocara/lib/pixman with this change, Xorg stopped crashing on my macppc. pixman uses cc -ftrapping-math which puts strictfp on each function call. llvm#72758 ok jca@ tobhe@ deraadt@
It would be nice to get this in. |
Please let us know if need us to commit this pr. @kernigh |
He does, but there was the issue of the test case being updated. |
If a function call has the strictfp attribute, its opcode changes from CALL to CALL_RM. If the call uses the secure PLT for 32-bit ELF, then it must getGlobalBaseReg() to set r30.
This fixes a bug that I described in (OpenBSD) macppc clang-16 -ftrapping-math crashes Xorg. The short version is that clang -ftrapping-math broke code like
int main(void) { time(NULL); }
by forgetting to set r30 before using the secure PLT.