-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[Xtensa] Lowering FRAMEADDR/RETURNADDR operations. #107363
[Xtensa] Lowering FRAMEADDR/RETURNADDR operations. #107363
Conversation
35d700d
to
a210ae9
Compare
@arsenm , @s-barannikov , PTAL to this PR whenever you have the time. |
MachineFunction &MF = DAG.getMachineFunction(); | ||
MachineFrameInfo &MFI = MF.getFrameInfo(); | ||
EVT VT = Op.getValueType(); | ||
unsigned RA = Xtensa::A0; |
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.
No reason to use this variable (but it should be Register/MCRegister)
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.
Thank you for comments. Fixed.
// check the depth | ||
// TODO: xtensa-gcc can handle this, by navigating through the stack, we | ||
// should be able to do this too | ||
assert((cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0) && |
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.
Shouldn't assert on this, it's not invalid IR. Langref states it returns "zero if it cannot be identified"
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.
Fixed. I hope that I understand correctly your comment,
SDValue XtensaTargetLowering::LowerFRAMEADDR(SDValue Op, | ||
SelectionDAG &DAG) const { | ||
// check the depth | ||
assert((cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0) && |
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.
Same
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.
Corrected
; CHECK-NEXT: ret | ||
%1 = call ptr @llvm.returnaddress(i32 0) | ||
ret ptr %1 | ||
} |
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.
Test the non-0 cases
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.
Added new tests
; CHECK-LABEL: test_frameaddress_0: | ||
; CHECK: or a2, a1, a1 | ||
; CHECK-NEXT: ret | ||
%1 = call ptr @llvm.frameaddress(i32 0) |
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.
Use named values in tests
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.
Corrected
@@ -0,0 +1,22 @@ | |||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | |||
; RUN: llc -mtriple=xtensa -verify-machineinstrs < %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.
Don't need -verify-machineinstrs
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.
Corrected
EVT VT = Op.getValueType(); | ||
SDLoc DL(Op); | ||
|
||
unsigned FrameRegister = Subtarget.getRegisterInfo()->getFrameRegister(MF); |
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.
Register
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.
Corrected
return SDValue(); | ||
|
||
MachineFunction &MF = DAG.getMachineFunction(); | ||
MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo(); |
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.
MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo(); | |
MachineFrameInfo &MFI = MF.getFrameInfo(); |
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.
Fixed
// An index of one to the parent's return address, and so on. | ||
// Depths > 0 not supported yet! | ||
if (Op.getConstantOperandVal(0) > 0) | ||
return SDValue(); |
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.
!= 0
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.
Fixed
// An index of zero corresponds to the current function's frame address. | ||
// An index of one to the parent's frame address, and so on. | ||
// Depths > 0 not supported yet! | ||
if (Op.getConstantOperandVal(0) > 0) |
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.
!= 0
No description provided.