mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[mips] Replace assertion by error message while lowering RETURNADDR
and FRAMEADDR
MIPS target supports lowering `RETURNADDR` and `FRAMEADDR` for a current frame only. It's better to show an error message then crash on assertion if `__builtin_return_address` is invoked with non-zero argument. llvm-svn: 355558
This commit is contained in:
parent
ef4c6a650d
commit
59eb4a19ba
@ -2376,8 +2376,11 @@ SDValue MipsTargetLowering::lowerFABS(SDValue Op, SelectionDAG &DAG) const {
|
||||
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);
|
||||
@ -2394,8 +2397,11 @@ SDValue MipsTargetLowering::lowerRETURNADDR(SDValue Op,
|
||||
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();
|
||||
|
11
test/CodeGen/Mips/frame-address-err.ll
Normal file
11
test/CodeGen/Mips/frame-address-err.ll
Normal file
@ -0,0 +1,11 @@
|
||||
; 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
|
||||
}
|
11
test/CodeGen/Mips/return_address_err.ll
Normal file
11
test/CodeGen/Mips/return_address_err.ll
Normal file
@ -0,0 +1,11 @@
|
||||
; 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user