SDValue MipsTargetLowering::
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.");
+ if (cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() != 0) {
+ DAG.getContext()->emitError(
+ "return address can be determined only for current frame");
+ return SDValue();
+ }
MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo();
MFI.setFrameAddressIsTaken(true);
return SDValue();
// check the depth
- assert((cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0) &&
- "Return address can be determined only for current frame.");
+ if (cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() != 0) {
+ DAG.getContext()->emitError(
+ "return address can be determined only for current frame");
+ return SDValue();
+ }
MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo &MFI = MF.getFrameInfo();
--- /dev/null
+; RUN: not llc -march=mips < %s 2>&1 | FileCheck %s
+
+declare i8* @llvm.frameaddress(i32) nounwind readnone
+
+define i8* @f() nounwind {
+entry:
+ %0 = call i8* @llvm.frameaddress(i32 1)
+ ret i8* %0
+
+; CHECK: error: return address can be determined only for current frame
+}
--- /dev/null
+; RUN: not llc -march=mips < %s 2>&1 | FileCheck %s
+
+declare i8* @llvm.returnaddress(i32) nounwind readnone
+
+define i8* @f() nounwind {
+entry:
+ %0 = call i8* @llvm.returnaddress(i32 1)
+ ret i8* %0
+
+; CHECK: error: return address can be determined only for current frame
+}