AMDGPU: Don't use report_fatal_error for unsupported call types
llvm-svn: 310004
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
index 4f65b40..6597f79 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
@@ -1001,8 +1001,9 @@
return AMDGPUCallLowering::CCAssignFnForReturn(CC, IsVarArg);
}
-SDValue AMDGPUTargetLowering::LowerCall(CallLoweringInfo &CLI,
- SmallVectorImpl<SDValue> &InVals) const {
+SDValue AMDGPUTargetLowering::lowerUnhandledCall(CallLoweringInfo &CLI,
+ SmallVectorImpl<SDValue> &InVals,
+ StringRef Reason) const {
SDValue Callee = CLI.Callee;
SelectionDAG &DAG = CLI.DAG;
@@ -1016,7 +1017,7 @@
FuncName = G->getGlobal()->getName();
DiagnosticInfoUnsupported NoCalls(
- Fn, "unsupported call to function " + FuncName, CLI.DL.getDebugLoc());
+ Fn, Reason + FuncName, CLI.DL.getDebugLoc());
DAG.getContext()->diagnose(NoCalls);
if (!CLI.IsTailCall) {
@@ -1027,6 +1028,11 @@
return DAG.getEntryNode();
}
+SDValue AMDGPUTargetLowering::LowerCall(CallLoweringInfo &CLI,
+ SmallVectorImpl<SDValue> &InVals) const {
+ return lowerUnhandledCall(CLI, InVals, "unsupported call to function ");
+}
+
SDValue AMDGPUTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
SelectionDAG &DAG) const {
const Function &Fn = *DAG.getMachineFunction().getFunction();
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
index 46c81f9..0a7d02e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
@@ -171,6 +171,10 @@
const SmallVectorImpl<ISD::OutputArg> &Outs,
const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
SelectionDAG &DAG) const override;
+
+ SDValue lowerUnhandledCall(CallLoweringInfo &CLI,
+ SmallVectorImpl<SDValue> &InVals,
+ StringRef Reason) const;
SDValue LowerCall(CallLoweringInfo &CLI,
SmallVectorImpl<SDValue> &InVals) const override;
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 68881ef..cec3abb 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -1888,8 +1888,7 @@
return;
const Function *CalleeFunc = CLI.CS.getCalledFunction();
- if (!CalleeFunc)
- report_fatal_error("indirect calls not handled");
+ assert(CalleeFunc);
SelectionDAG &DAG = CLI.DAG;
const SDLoc &DL = CLI.DL;
@@ -1976,13 +1975,24 @@
bool IsThisReturn = false;
MachineFunction &MF = DAG.getMachineFunction();
+ if (IsVarArg) {
+ return lowerUnhandledCall(CLI, InVals,
+ "unsupported call to variadic function ");
+ }
+
+ if (!CLI.CS.getCalledFunction()) {
+ return lowerUnhandledCall(CLI, InVals,
+ "unsupported indirect call to function ");
+ }
+
+ if (IsTailCall && MF.getTarget().Options.GuaranteedTailCallOpt) {
+ return lowerUnhandledCall(CLI, InVals,
+ "unsupported required tail call to function ");
+ }
+
// TODO: Implement tail calls.
IsTailCall = false;
- if (IsVarArg || MF.getTarget().Options.GuaranteedTailCallOpt) {
- report_fatal_error("varargs and tail calls not implemented");
- }
-
if (GlobalAddressSDNode *GA = dyn_cast<GlobalAddressSDNode>(Callee)) {
// FIXME: Remove this hack for function pointer types.
const GlobalValue *GV = GA->getGlobal();