Skip to content

Commit 1bcece7

Browse files
committed
Truncate the arguments of llvm.frameaddress / llvm.returnaddress intrinsics from i32 to platform's largest native type
llvm-svn: 90741
1 parent ff4ab51 commit 1bcece7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,9 @@ bool DAGTypeLegalizer::ExpandIntegerOperand(SDNode *N, unsigned OpNo) {
19961996
case ISD::SRA:
19971997
case ISD::SRL:
19981998
case ISD::ROTL:
1999-
case ISD::ROTR: Res = ExpandIntOp_Shift(N); break;
1999+
case ISD::ROTR: Res = ExpandIntOp_Shift(N); break;
2000+
case ISD::RETURNADDR:
2001+
case ISD::FRAMEADDR: Res = ExpandIntOp_RETURNADDR(N); break;
20002002
}
20012003

20022004
// If the result is null, the sub-method took care of registering results etc.
@@ -2180,6 +2182,15 @@ SDValue DAGTypeLegalizer::ExpandIntOp_Shift(SDNode *N) {
21802182
return DAG.UpdateNodeOperands(SDValue(N, 0), N->getOperand(0), Lo);
21812183
}
21822184

2185+
SDValue DAGTypeLegalizer::ExpandIntOp_RETURNADDR(SDNode *N) {
2186+
// The argument of RETURNADDR / FRAMEADDR builtin is 32 bit contant. This
2187+
// surely makes pretty nice problems on 8/16 bit targets. Just truncate this
2188+
// constant to valid type.
2189+
SDValue Lo, Hi;
2190+
GetExpandedInteger(N->getOperand(0), Lo, Hi);
2191+
return DAG.UpdateNodeOperands(SDValue(N, 0), Lo);
2192+
}
2193+
21832194
SDValue DAGTypeLegalizer::ExpandIntOp_SINT_TO_FP(SDNode *N) {
21842195
SDValue Op = N->getOperand(0);
21852196
EVT DstVT = N->getValueType(0);

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ class VISIBILITY_HIDDEN DAGTypeLegalizer {
362362
SDValue ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo);
363363
SDValue ExpandIntOp_TRUNCATE(SDNode *N);
364364
SDValue ExpandIntOp_UINT_TO_FP(SDNode *N);
365+
SDValue ExpandIntOp_RETURNADDR(SDNode *N);
365366

366367
void IntegerExpandSetCCOperands(SDValue &NewLHS, SDValue &NewRHS,
367368
ISD::CondCode &CCCode, DebugLoc dl);

0 commit comments

Comments
 (0)