[PATCH] D136917: [LoongArch] Replace assertion by error message while lowering RETURNADDR and FRAMEADDR
Gong LingQin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 30 18:44:00 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbe8a2b98da58: [LoongArch] Replace assertion by error message while lowering RETURNADDR and… (authored by gonglingqin).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136917/new/
https://reviews.llvm.org/D136917
Files:
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll
Index: llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll
===================================================================
--- llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll
+++ llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll
@@ -16,3 +16,16 @@
ret ptr %1
}
+define ptr @non_zero_frameaddress() nounwind {
+; CHECK: frame address can only be determined for the current frame
+ %1 = call ptr @llvm.frameaddress(i32 1)
+ ret ptr %1
+}
+
+
+define ptr @non_zero_returnaddress() nounwind {
+; CHECK: return address can only be determined for the current frame
+ %1 = call ptr @llvm.returnaddress(i32 1)
+ ret ptr %1
+}
+
Index: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
===================================================================
--- llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -239,11 +239,11 @@
}
// Currently only support lowering frame address for current frame.
- unsigned Depth = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
- assert((Depth == 0) &&
- "Frame address can only be determined for current frame.");
- if (Depth != 0)
+ if (cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() != 0) {
+ DAG.getContext()->emitError(
+ "frame address can only be determined for the current frame");
return SDValue();
+ }
MachineFunction &MF = DAG.getMachineFunction();
MF.getFrameInfo().setFrameAddressIsTaken(true);
@@ -259,11 +259,11 @@
return SDValue();
// Currently only support lowering return address for current frame.
- unsigned Depth = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
- assert((Depth == 0) &&
- "Return address can only be determined for current frame.");
- if (Depth != 0)
+ if (cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() != 0) {
+ DAG.getContext()->emitError(
+ "return address can only be determined for the current frame");
return SDValue();
+ }
MachineFunction &MF = DAG.getMachineFunction();
MF.getFrameInfo().setReturnAddressIsTaken(true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136917.471891.patch
Type: text/x-patch
Size: 2117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221031/8f761d45/attachment.bin>
More information about the llvm-commits
mailing list