-
Notifications
You must be signed in to change notification settings - Fork 15.9k
[Xtensa] Lowering FRAMEADDR/RETURNADDR operations. #107363
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -594,6 +594,26 @@ SDValue XtensaTargetLowering::LowerSELECT_CC(SDValue Op, | |||||
| FalseValue, TargetCC); | ||||||
| } | ||||||
|
|
||||||
| SDValue XtensaTargetLowering::LowerRETURNADDR(SDValue Op, | ||||||
| SelectionDAG &DAG) const { | ||||||
| // 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) && | ||||||
| "Return address can be determined only for current frame."); | ||||||
|
|
||||||
| MachineFunction &MF = DAG.getMachineFunction(); | ||||||
| MachineFrameInfo &MFI = MF.getFrameInfo(); | ||||||
| EVT VT = Op.getValueType(); | ||||||
| unsigned RA = Xtensa::A0; | ||||||
|
||||||
| MFI.setReturnAddressIsTaken(true); | ||||||
|
|
||||||
| // Return RA, which contains the return address. Mark it an implicit | ||||||
| // live-in. | ||||||
| unsigned Register = MF.addLiveIn(RA, getRegClassFor(MVT::i32)); | ||||||
arsenm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| return DAG.getCopyFromReg(DAG.getEntryNode(), SDLoc(Op), Register, VT); | ||||||
| } | ||||||
|
|
||||||
| SDValue XtensaTargetLowering::LowerImmediate(SDValue Op, | ||||||
| SelectionDAG &DAG) const { | ||||||
| const ConstantSDNode *CN = cast<ConstantSDNode>(Op); | ||||||
|
|
@@ -722,6 +742,24 @@ SDValue XtensaTargetLowering::LowerSTACKRESTORE(SDValue Op, | |||||
| Op.getOperand(1)); | ||||||
| } | ||||||
|
|
||||||
| SDValue XtensaTargetLowering::LowerFRAMEADDR(SDValue Op, | ||||||
| SelectionDAG &DAG) const { | ||||||
| // check the depth | ||||||
| assert((cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0) && | ||||||
|
||||||
| "Frame address can only be determined for current frame."); | ||||||
|
|
||||||
| MachineFunction &MF = DAG.getMachineFunction(); | ||||||
| MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo(); | ||||||
|
||||||
| 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
Outdated
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 \ | ||
|
||
| ; RUN: | FileCheck %s | ||
|
|
||
| declare ptr @llvm.frameaddress(i32) | ||
| declare ptr @llvm.returnaddress(i32) | ||
|
|
||
| define ptr @test_frameaddress_0() nounwind { | ||
| ; CHECK-LABEL: test_frameaddress_0: | ||
| ; CHECK: or a2, a1, a1 | ||
| ; CHECK-NEXT: ret | ||
| %1 = call ptr @llvm.frameaddress(i32 0) | ||
|
||
| ret ptr %1 | ||
| } | ||
|
|
||
| define ptr @test_returnaddress_0() nounwind { | ||
| ; CHECK-LABEL: test_returnaddress_0: | ||
| ; CHECK: or a2, a0, a0 | ||
| ; CHECK-NEXT: ret | ||
| %1 = call ptr @llvm.returnaddress(i32 0) | ||
| ret ptr %1 | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test the non-0 cases
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added new 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.
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,