-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[Mips] Fix compiler crash when returning fp128 after calling a functi… #117525
Changes from all commits
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 |
---|---|---|
|
@@ -95,14 +95,13 @@ void MipsCCState::PreAnalyzeCallResultForF128( | |
|
||
/// Identify lowered values that originated from f128 or float arguments and | ||
/// record this for use by RetCC_MipsN. | ||
void MipsCCState::PreAnalyzeReturnForF128( | ||
const SmallVectorImpl<ISD::OutputArg> &Outs) { | ||
const MachineFunction &MF = getMachineFunction(); | ||
void MipsCCState::PreAnalyzeCallReturnForF128( | ||
const SmallVectorImpl<ISD::OutputArg> &Outs, const Type *RetTy) { | ||
for (unsigned i = 0; i < Outs.size(); ++i) { | ||
OriginalArgWasF128.push_back( | ||
originalTypeIsF128(MF.getFunction().getReturnType(), nullptr)); | ||
originalTypeIsF128(RetTy, nullptr)); | ||
OriginalArgWasFloat.push_back( | ||
MF.getFunction().getReturnType()->isFloatingPointTy()); | ||
RetTy->isFloatingPointTy()); | ||
} | ||
} | ||
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. Can we drop PreAnalyzeReturnForF128 now? It should be the same as PreAnalyzeCallReturnForF128 and passing MD.getFunction().getReturnType(). 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. OK, good idea. 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.
Applied. 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. Ping |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ class MipsCCState : public CCState { | |
|
||
/// Identify lowered values that originated from f128 arguments and record | ||
/// this for use by RetCC_MipsN. | ||
void PreAnalyzeReturnForF128(const SmallVectorImpl<ISD::OutputArg> &Outs); | ||
void PreAnalyzeCallReturnForF128(const SmallVectorImpl<ISD::OutputArg> &Outs, const Type *RetTy); | ||
|
||
/// Identify lowered values that originated from f128 arguments and record | ||
/// this. | ||
|
@@ -167,10 +167,11 @@ class MipsCCState : public CCState { | |
|
||
void PreAnalyzeReturn(const SmallVectorImpl<ISD::OutputArg> &Outs, | ||
CCAssignFn Fn) { | ||
const MachineFunction &MF = getMachineFunction(); | ||
OriginalArgWasFloat.clear(); | ||
OriginalArgWasF128.clear(); | ||
OriginalArgWasFloatVector.clear(); | ||
PreAnalyzeReturnForF128(Outs); | ||
PreAnalyzeCallReturnForF128(Outs, MF.getFunction().getReturnType()); | ||
PreAnalyzeReturnForVectorFloat(Outs); | ||
} | ||
|
||
|
@@ -182,7 +183,8 @@ class MipsCCState : public CCState { | |
|
||
bool CheckReturn(const SmallVectorImpl<ISD::OutputArg> &ArgsFlags, | ||
CCAssignFn Fn) { | ||
PreAnalyzeReturnForF128(ArgsFlags); | ||
const MachineFunction &MF = getMachineFunction(); | ||
PreAnalyzeCallReturnForF128(ArgsFlags, MF.getFunction().getReturnType()); | ||
PreAnalyzeReturnForVectorFloat(ArgsFlags); | ||
bool Return = CCState::CheckReturn(ArgsFlags, Fn); | ||
OriginalArgWasFloat.clear(); | ||
|
@@ -191,6 +193,16 @@ class MipsCCState : public CCState { | |
return Return; | ||
} | ||
|
||
bool CheckCallReturn(const SmallVectorImpl<ISD::OutputArg> &ArgsFlags, | ||
CCAssignFn Fn, const Type *RetTy) { | ||
PreAnalyzeCallReturnForF128(ArgsFlags, RetTy); | ||
PreAnalyzeReturnForVectorFloat(ArgsFlags); | ||
Comment on lines
+198
to
+199
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. I don't understand how this fixes it, but this looks like hacking around something that shouldn't require special casing 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. Add a new function to check whether call funtion return type was origin from fp128. |
||
bool Return = CCState::CheckReturn(ArgsFlags, Fn); | ||
OriginalArgWasFloat.clear(); | ||
OriginalArgWasF128.clear(); | ||
OriginalArgWasFloatVector.clear(); | ||
return Return; | ||
} | ||
bool WasOriginalArgF128(unsigned ValNo) { return OriginalArgWasF128[ValNo]; } | ||
bool WasOriginalArgFloat(unsigned ValNo) { | ||
return OriginalArgWasFloat[ValNo]; | ||
|
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.
A new parameter should not be necessary. Outs should already correspond to the decomposed aggregate type derived from the original IR type
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.
Because in Mips backend, when process hook function CanLowerReturn, they now use MF function return type to check whether call function return type was origin from fp128.
In fact, when they check whether MF function return type was origin from fp128, they should use MF function return type; when they check whether call function return type was origin from fp128, they should use call function return type.
So, we need a new parameter to specify the right return type.
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.
We can know each element value type in
Outs
, but we can not get the call return type fromOuts
. So I think it is necessary to add a new parameter.