[llvm] r259498 - Refactor backend diagnostics for unsupported features
Oliver Stannard via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 2 05:52:43 PST 2016
Author: olista01
Date: Tue Feb 2 07:52:43 2016
New Revision: 259498
URL: http://llvm.org/viewvc/llvm-project?rev=259498&view=rev
Log:
Refactor backend diagnostics for unsupported features
Re-commit of r258951 after fixing layering violation.
The BPF and WebAssembly backends had identical code for emitting errors
for unsupported features, and AMDGPU had very similar code. This merges
them all into one DiagnosticInfo subclass, that can be used by any
backend.
There should be minimal functional changes here, but some AMDGPU tests
have been updated for the new format of errors (it used a slightly
different format to BPF and WebAssembly). The AMDGPU error messages will
now benefit from having precise source locations when debug info is
available.
Removed:
llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h
Modified:
llvm/trunk/include/llvm/IR/DiagnosticInfo.h
llvm/trunk/lib/IR/DiagnosticInfo.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt
llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/trunk/lib/Target/BPF/BPFISelLowering.cpp
llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/trunk/test/CodeGen/AMDGPU/addrspacecast.ll
llvm/trunk/test/CodeGen/AMDGPU/call.ll
llvm/trunk/test/CodeGen/AMDGPU/dynamic_stackalloc.ll
llvm/trunk/test/CodeGen/AMDGPU/global-zero-initializer.ll
llvm/trunk/test/CodeGen/AMDGPU/lds-initializer.ll
llvm/trunk/test/CodeGen/AMDGPU/lds-zero-initializer.ll
llvm/trunk/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll
llvm/trunk/test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll
llvm/trunk/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll
Modified: llvm/trunk/include/llvm/IR/DiagnosticInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DiagnosticInfo.h?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DiagnosticInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DiagnosticInfo.h Tue Feb 2 07:52:43 2016
@@ -60,6 +60,7 @@ enum DiagnosticKind {
DK_OptimizationFailure,
DK_MIRParser,
DK_PGOProfile,
+ DK_Unsupported,
DK_FirstPluginKind
};
@@ -275,8 +276,42 @@ private:
const Twine &Msg;
};
+/// Common features for diagnostics with an associated DebugLoc
+class DiagnosticInfoWithDebugLocBase : public DiagnosticInfo {
+public:
+ /// \p Fn is the function where the diagnostic is being emitted. \p DLoc is
+ /// the location information to use in the diagnostic.
+ DiagnosticInfoWithDebugLocBase(enum DiagnosticKind Kind,
+ enum DiagnosticSeverity Severity,
+ const Function &Fn,
+ const DebugLoc &DLoc)
+ : DiagnosticInfo(Kind, Severity), Fn(Fn), DLoc(DLoc) {}
+
+ /// Return true if location information is available for this diagnostic.
+ bool isLocationAvailable() const;
+
+ /// Return a string with the location information for this diagnostic
+ /// in the format "file:line:col". If location information is not available,
+ /// it returns "<unknown>:0:0".
+ const std::string getLocationStr() const;
+
+ /// Return location information for this diagnostic in three parts:
+ /// the source file name, line number and column.
+ void getLocation(StringRef *Filename, unsigned *Line, unsigned *Column) const;
+
+ const Function &getFunction() const { return Fn; }
+ const DebugLoc &getDebugLoc() const { return DLoc; }
+
+private:
+ /// Function where this diagnostic is triggered.
+ const Function &Fn;
+
+ /// Debug location where this diagnostic is triggered.
+ DebugLoc DLoc;
+};
+
/// Common features for diagnostics dealing with optimization remarks.
-class DiagnosticInfoOptimizationBase : public DiagnosticInfo {
+class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithDebugLocBase {
public:
/// \p PassName is the name of the pass emitting this diagnostic.
/// \p Fn is the function where the diagnostic is being emitted. \p DLoc is
@@ -289,8 +324,8 @@ public:
enum DiagnosticSeverity Severity,
const char *PassName, const Function &Fn,
const DebugLoc &DLoc, const Twine &Msg)
- : DiagnosticInfo(Kind, Severity), PassName(PassName), Fn(Fn), DLoc(DLoc),
- Msg(Msg) {}
+ : DiagnosticInfoWithDebugLocBase(Kind, Severity, Fn, DLoc),
+ PassName(PassName), Msg(Msg) {}
/// \see DiagnosticInfo::print.
void print(DiagnosticPrinter &DP) const override;
@@ -302,21 +337,7 @@ public:
/// in BackendConsumer::OptimizationRemarkHandler).
virtual bool isEnabled() const = 0;
- /// Return true if location information is available for this diagnostic.
- bool isLocationAvailable() const;
-
- /// Return a string with the location information for this diagnostic
- /// in the format "file:line:col". If location information is not available,
- /// it returns "<unknown>:0:0".
- const std::string getLocationStr() const;
-
- /// Return location information for this diagnostic in three parts:
- /// the source file name, line number and column.
- void getLocation(StringRef *Filename, unsigned *Line, unsigned *Column) const;
-
const char *getPassName() const { return PassName; }
- const Function &getFunction() const { return Fn; }
- const DebugLoc &getDebugLoc() const { return DLoc; }
const Twine &getMsg() const { return Msg; }
private:
@@ -325,12 +346,6 @@ private:
/// be emitted.
const char *PassName;
- /// Function where this diagnostic is triggered.
- const Function &Fn;
-
- /// Debug location where this diagnostic is triggered.
- DebugLoc DLoc;
-
/// Message to report.
const Twine &Msg;
};
@@ -572,6 +587,33 @@ public:
bool isEnabled() const override;
};
+/// Diagnostic information for unsupported feature in backend.
+class DiagnosticInfoUnsupported
+ : public DiagnosticInfoWithDebugLocBase {
+private:
+ const Twine &Msg;
+
+public:
+ /// \p Fn is the function where the diagnostic is being emitted. \p DLoc is
+ /// the location information to use in the diagnostic. If line table
+ /// information is available, the diagnostic will include the source code
+ /// location. \p Msg is the message to show. Note that this class does not
+ /// copy this message, so this reference must be valid for the whole life time
+ /// of the diagnostic.
+ DiagnosticInfoUnsupported(const Function &Fn, const Twine &Msg,
+ DebugLoc DLoc = DebugLoc())
+ : DiagnosticInfoWithDebugLocBase(DK_Unsupported, DS_Error, Fn, DLoc),
+ Msg(Msg) {}
+
+ static bool classof(const DiagnosticInfo *DI) {
+ return DI->getKind() == DK_Unsupported;
+ }
+
+ const Twine &getMessage() const { return Msg; }
+
+ void print(DiagnosticPrinter &DP) const;
+};
+
/// Emit a warning when loop vectorization is specified but fails. \p Fn is the
/// function triggering the warning, \p DLoc is the debug location where the
/// diagnostic is generated. \p Msg is the message string to use.
Modified: llvm/trunk/lib/IR/DiagnosticInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DiagnosticInfo.cpp?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DiagnosticInfo.cpp (original)
+++ llvm/trunk/lib/IR/DiagnosticInfo.cpp Tue Feb 2 07:52:43 2016
@@ -138,11 +138,11 @@ void DiagnosticInfoPGOProfile::print(Dia
DP << getMsg();
}
-bool DiagnosticInfoOptimizationBase::isLocationAvailable() const {
+bool DiagnosticInfoWithDebugLocBase::isLocationAvailable() const {
return getDebugLoc();
}
-void DiagnosticInfoOptimizationBase::getLocation(StringRef *Filename,
+void DiagnosticInfoWithDebugLocBase::getLocation(StringRef *Filename,
unsigned *Line,
unsigned *Column) const {
DILocation *L = getDebugLoc();
@@ -152,7 +152,7 @@ void DiagnosticInfoOptimizationBase::get
*Column = L->getColumn();
}
-const std::string DiagnosticInfoOptimizationBase::getLocationStr() const {
+const std::string DiagnosticInfoWithDebugLocBase::getLocationStr() const {
StringRef Filename("<unknown>");
unsigned Line = 0;
unsigned Column = 0;
@@ -230,6 +230,16 @@ bool DiagnosticInfoOptimizationFailure::
return getSeverity() == DS_Warning;
}
+void DiagnosticInfoUnsupported::print(DiagnosticPrinter &DP) const {
+ std::string Str;
+ raw_string_ostream OS(Str);
+
+ OS << getLocationStr() << ": in function " << getFunction().getName() << ' '
+ << *getFunction().getFunctionType() << ": " << Msg << '\n';
+ OS.flush();
+ DP << Str;
+}
+
void llvm::emitLoopVectorizeWarning(LLVMContext &Ctx, const Function &Fn,
const DebugLoc &DLoc, const Twine &Msg) {
Ctx.diagnose(DiagnosticInfoOptimizationFailure(
Removed: llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp?rev=259497&view=auto
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp (removed)
@@ -1,26 +0,0 @@
-//===-- AMDGPUDiagnosticInfoUnsupported.cpp -------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "AMDGPUDiagnosticInfoUnsupported.h"
-
-using namespace llvm;
-
-DiagnosticInfoUnsupported::DiagnosticInfoUnsupported(
- const Function &Fn,
- const Twine &Desc,
- DiagnosticSeverity Severity)
- : DiagnosticInfo(getKindID(), Severity),
- Description(Desc),
- Fn(Fn) { }
-
-int DiagnosticInfoUnsupported::KindID = 0;
-
-void DiagnosticInfoUnsupported::print(DiagnosticPrinter &DP) const {
- DP << "unsupported " << getDescription() << " in " << Fn.getName();
-}
Removed: llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h?rev=259497&view=auto
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h (removed)
@@ -1,48 +0,0 @@
-//===-- AMDGPUDiagnosticInfoUnsupported.h - Error reporting -----*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUDIAGNOSTICINFOUNSUPPORTED_H
-#define LLVM_LIB_TARGET_AMDGPU_AMDGPUDIAGNOSTICINFOUNSUPPORTED_H
-
-#include "llvm/IR/DiagnosticInfo.h"
-#include "llvm/IR/DiagnosticPrinter.h"
-
-namespace llvm {
-
-/// Diagnostic information for unimplemented or unsupported feature reporting.
-class DiagnosticInfoUnsupported : public DiagnosticInfo {
-private:
- const Twine &Description;
- const Function &Fn;
-
- static int KindID;
-
- static int getKindID() {
- if (KindID == 0)
- KindID = llvm::getNextAvailablePluginDiagnosticKind();
- return KindID;
- }
-
-public:
- DiagnosticInfoUnsupported(const Function &Fn, const Twine &Desc,
- DiagnosticSeverity Severity = DS_Error);
-
- const Function &getFunction() const { return Fn; }
- const Twine &getDescription() const { return Description; }
-
- void print(DiagnosticPrinter &DP) const override;
-
- static bool classof(const DiagnosticInfo *DI) {
- return DI->getKind() == getKindID();
- }
-};
-
-}
-
-#endif
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp Tue Feb 2 07:52:43 2016
@@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//
-#include "AMDGPUDiagnosticInfoUnsupported.h"
#include "AMDGPUInstrInfo.h"
#include "AMDGPUISelLowering.h" // For AMDGPUISD
#include "AMDGPURegisterInfo.h"
@@ -27,6 +26,7 @@
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/SelectionDAGISel.h"
+#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
using namespace llvm;
@@ -1219,8 +1219,8 @@ SDNode *AMDGPUDAGToDAGISel::SelectAddrSp
SDLoc DL(N);
const MachineFunction &MF = CurDAG->getMachineFunction();
- DiagnosticInfoUnsupported NotImplemented(*MF.getFunction(),
- "addrspacecast not implemented");
+ DiagnosticInfoUnsupported NotImplemented(
+ *MF.getFunction(), "addrspacecast not implemented", DL.getDebugLoc());
CurDAG->getContext()->diagnose(NotImplemented);
assert(Subtarget->hasFlatAddressSpace() &&
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp Tue Feb 2 07:52:43 2016
@@ -15,7 +15,6 @@
#include "AMDGPUISelLowering.h"
#include "AMDGPU.h"
-#include "AMDGPUDiagnosticInfoUnsupported.h"
#include "AMDGPUFrameLowering.h"
#include "AMDGPUIntrinsicInfo.h"
#include "AMDGPURegisterInfo.h"
@@ -28,6 +27,7 @@
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DiagnosticInfo.h"
#include "SIInstrInfo.h"
using namespace llvm;
@@ -609,7 +609,8 @@ SDValue AMDGPUTargetLowering::LowerCall(
else if (const GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
FuncName = G->getGlobal()->getName();
- DiagnosticInfoUnsupported NoCalls(Fn, "call to function " + FuncName);
+ DiagnosticInfoUnsupported NoCalls(
+ Fn, "unsupported call to function " + FuncName, CLI.DL.getDebugLoc());
DAG.getContext()->diagnose(NoCalls);
return SDValue();
}
@@ -618,7 +619,8 @@ SDValue AMDGPUTargetLowering::LowerDYNAM
SelectionDAG &DAG) const {
const Function &Fn = *DAG.getMachineFunction().getFunction();
- DiagnosticInfoUnsupported NoDynamicAlloca(Fn, "dynamic alloca");
+ DiagnosticInfoUnsupported NoDynamicAlloca(Fn, "unsupported dynamic alloca",
+ SDLoc(Op).getDebugLoc());
DAG.getContext()->diagnose(NoDynamicAlloca);
return SDValue();
}
@@ -865,8 +867,8 @@ SDValue AMDGPUTargetLowering::LowerGloba
}
const Function &Fn = *DAG.getMachineFunction().getFunction();
- DiagnosticInfoUnsupported BadInit(Fn,
- "initializer for address space");
+ DiagnosticInfoUnsupported BadInit(
+ Fn, "unsupported initializer for address space", SDLoc(Op).getDebugLoc());
DAG.getContext()->diagnose(BadInit);
return SDValue();
}
Modified: llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt (original)
+++ llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt Tue Feb 2 07:52:43 2016
@@ -18,7 +18,6 @@ add_llvm_target(AMDGPUCodeGen
AMDGPUAnnotateKernelFeatures.cpp
AMDGPUAnnotateUniformValues.cpp
AMDGPUAsmPrinter.cpp
- AMDGPUDiagnosticInfoUnsupported.cpp
AMDGPUFrameLowering.cpp
AMDGPUTargetObjectFile.cpp
AMDGPUIntrinsicInfo.cpp
Modified: llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp Tue Feb 2 07:52:43 2016
@@ -20,7 +20,6 @@
#include "SIISelLowering.h"
#include "AMDGPU.h"
-#include "AMDGPUDiagnosticInfoUnsupported.h"
#include "AMDGPUIntrinsicInfo.h"
#include "AMDGPUSubtarget.h"
#include "SIInstrInfo.h"
@@ -32,6 +31,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/SelectionDAG.h"
+#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/ADT/SmallString.h"
@@ -591,7 +591,8 @@ SDValue SITargetLowering::LowerFormalArg
if (Subtarget->isAmdHsaOS() && Info->getShaderType() != ShaderType::COMPUTE) {
const Function *Fn = MF.getFunction();
- DiagnosticInfoUnsupported NoGraphicsHSA(*Fn, "non-compute shaders with HSA");
+ DiagnosticInfoUnsupported NoGraphicsHSA(
+ *Fn, "unsupported non-compute shaders with HSA", DL.getDebugLoc());
DAG.getContext()->diagnose(NoGraphicsHSA);
return SDValue();
}
@@ -1327,8 +1328,9 @@ SDValue SITargetLowering::LowerINTRINSIC
switch (IntrinsicID) {
case Intrinsic::amdgcn_dispatch_ptr:
if (!Subtarget->isAmdHsaOS()) {
- DiagnosticInfoUnsupported BadIntrin(*MF.getFunction(),
- "hsa intrinsic without hsa target");
+ DiagnosticInfoUnsupported BadIntrin(
+ *MF.getFunction(), "unsupported hsa intrinsic without hsa target",
+ DL.getDebugLoc());
DAG.getContext()->diagnose(BadIntrin);
return DAG.getUNDEF(VT);
}
Modified: llvm/trunk/lib/Target/BPF/BPFISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFISelLowering.cpp?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/BPF/BPFISelLowering.cpp Tue Feb 2 07:52:43 2016
@@ -34,58 +34,21 @@ using namespace llvm;
#define DEBUG_TYPE "bpf-lower"
-namespace {
-
-// Diagnostic information for unimplemented or unsupported feature reporting.
-class DiagnosticInfoUnsupported : public DiagnosticInfo {
-private:
- // Debug location where this diagnostic is triggered.
- DebugLoc DLoc;
- const Twine &Description;
- const Function &Fn;
- SDValue Value;
-
- static int KindID;
-
- static int getKindID() {
- if (KindID == 0)
- KindID = llvm::getNextAvailablePluginDiagnosticKind();
- return KindID;
- }
-
-public:
- DiagnosticInfoUnsupported(SDLoc DLoc, const Function &Fn, const Twine &Desc,
- SDValue Value)
- : DiagnosticInfo(getKindID(), DS_Error), DLoc(DLoc.getDebugLoc()),
- Description(Desc), Fn(Fn), Value(Value) {}
-
- void print(DiagnosticPrinter &DP) const override {
- std::string Str;
- raw_string_ostream OS(Str);
-
- if (DLoc) {
- auto DIL = DLoc.get();
- StringRef Filename = DIL->getFilename();
- unsigned Line = DIL->getLine();
- unsigned Column = DIL->getColumn();
- OS << Filename << ':' << Line << ':' << Column << ' ';
- }
-
- OS << "in function " << Fn.getName() << ' ' << *Fn.getFunctionType() << '\n'
- << Description;
- if (Value)
- Value->print(OS);
- OS << '\n';
- OS.flush();
- DP << Str;
- }
-
- static bool classof(const DiagnosticInfo *DI) {
- return DI->getKind() == getKindID();
- }
-};
+static void fail(SDLoc DL, SelectionDAG &DAG, const char *Msg) {
+ MachineFunction &MF = DAG.getMachineFunction();
+ DAG.getContext()->diagnose(
+ DiagnosticInfoUnsupported(*MF.getFunction(), Msg, DL.getDebugLoc()));
+}
-int DiagnosticInfoUnsupported::KindID = 0;
+static void fail(SDLoc DL, SelectionDAG &DAG, const char *Msg, SDValue Val) {
+ MachineFunction &MF = DAG.getMachineFunction();
+ std::string Str;
+ raw_string_ostream OS(Str);
+ OS << Msg;
+ Val->print(OS);
+ OS.flush();
+ DAG.getContext()->diagnose(
+ DiagnosticInfoUnsupported(*MF.getFunction(), Str, DL.getDebugLoc()));
}
BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM,
@@ -236,17 +199,12 @@ SDValue BPFTargetLowering::LowerFormalAr
InVals.push_back(ArgValue);
}
} else {
- DiagnosticInfoUnsupported Err(DL, *MF.getFunction(),
- "defined with too many args", SDValue());
- DAG.getContext()->diagnose(Err);
+ fail(DL, DAG, "defined with too many args");
}
}
if (IsVarArg || MF.getFunction()->hasStructRetAttr()) {
- DiagnosticInfoUnsupported Err(
- DL, *MF.getFunction(),
- "functions with VarArgs or StructRet are not supported", SDValue());
- DAG.getContext()->diagnose(Err);
+ fail(DL, DAG, "functions with VarArgs or StructRet are not supported");
}
return Chain;
@@ -285,9 +243,7 @@ SDValue BPFTargetLowering::LowerCall(Tar
unsigned NumBytes = CCInfo.getNextStackOffset();
if (Outs.size() >= 6) {
- DiagnosticInfoUnsupported Err(CLI.DL, *MF.getFunction(),
- "too many args to ", Callee);
- DAG.getContext()->diagnose(Err);
+ fail(CLI.DL, DAG, "too many args to ", Callee);
}
for (auto &Arg : Outs) {
@@ -295,9 +251,7 @@ SDValue BPFTargetLowering::LowerCall(Tar
if (!Flags.isByVal())
continue;
- DiagnosticInfoUnsupported Err(CLI.DL, *MF.getFunction(),
- "pass by value not supported ", Callee);
- DAG.getContext()->diagnose(Err);
+ fail(CLI.DL, DAG, "pass by value not supported ", Callee);
}
auto PtrVT = getPointerTy(MF.getDataLayout());
@@ -398,9 +352,7 @@ BPFTargetLowering::LowerReturn(SDValue C
CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, *DAG.getContext());
if (MF.getFunction()->getReturnType()->isAggregateType()) {
- DiagnosticInfoUnsupported Err(DL, *MF.getFunction(),
- "only integer returns supported", SDValue());
- DAG.getContext()->diagnose(Err);
+ fail(DL, DAG, "only integer returns supported");
}
// Analize return values.
@@ -443,9 +395,7 @@ SDValue BPFTargetLowering::LowerCallResu
CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, *DAG.getContext());
if (Ins.size() >= 2) {
- DiagnosticInfoUnsupported Err(DL, *MF.getFunction(),
- "only small returns supported", SDValue());
- DAG.getContext()->diagnose(Err);
+ fail(DL, DAG, "only small returns supported");
}
CCInfo.AnalyzeCallResult(Ins, RetCC_BPF64);
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp Tue Feb 2 07:52:43 2016
@@ -35,61 +35,6 @@ using namespace llvm;
#define DEBUG_TYPE "wasm-lower"
-namespace {
-// Diagnostic information for unimplemented or unsupported feature reporting.
-// TODO: This code is copied from BPF and AMDGPU; consider factoring it out
-// and sharing code.
-class DiagnosticInfoUnsupported final : public DiagnosticInfo {
-private:
- // Debug location where this diagnostic is triggered.
- DebugLoc DLoc;
- const Twine &Description;
- const Function &Fn;
- SDValue Value;
-
- static int KindID;
-
- static int getKindID() {
- if (KindID == 0)
- KindID = llvm::getNextAvailablePluginDiagnosticKind();
- return KindID;
- }
-
-public:
- DiagnosticInfoUnsupported(SDLoc DLoc, const Function &Fn, const Twine &Desc,
- SDValue Value)
- : DiagnosticInfo(getKindID(), DS_Error), DLoc(DLoc.getDebugLoc()),
- Description(Desc), Fn(Fn), Value(Value) {}
-
- void print(DiagnosticPrinter &DP) const override {
- std::string Str;
- raw_string_ostream OS(Str);
-
- if (DLoc) {
- auto DIL = DLoc.get();
- StringRef Filename = DIL->getFilename();
- unsigned Line = DIL->getLine();
- unsigned Column = DIL->getColumn();
- OS << Filename << ':' << Line << ':' << Column << ' ';
- }
-
- OS << "in function " << Fn.getName() << ' ' << *Fn.getFunctionType() << '\n'
- << Description;
- if (Value)
- Value->print(OS);
- OS << '\n';
- OS.flush();
- DP << Str;
- }
-
- static bool classof(const DiagnosticInfo *DI) {
- return DI->getKind() == getKindID();
- }
-};
-
-int DiagnosticInfoUnsupported::KindID = 0;
-} // end anonymous namespace
-
WebAssemblyTargetLowering::WebAssemblyTargetLowering(
const TargetMachine &TM, const WebAssemblySubtarget &STI)
: TargetLowering(TM), Subtarget(&STI) {
@@ -310,7 +255,7 @@ bool WebAssemblyTargetLowering::allowsMi
static void fail(SDLoc DL, SelectionDAG &DAG, const char *msg) {
MachineFunction &MF = DAG.getMachineFunction();
DAG.getContext()->diagnose(
- DiagnosticInfoUnsupported(DL, *MF.getFunction(), msg, SDValue()));
+ DiagnosticInfoUnsupported(*MF.getFunction(), msg, DL.getDebugLoc()));
}
// Test whether the given calling convention is supported.
Modified: llvm/trunk/test/CodeGen/AMDGPU/addrspacecast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/addrspacecast.ll?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/addrspacecast.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/addrspacecast.ll Tue Feb 2 07:52:43 2016
@@ -1,6 +1,6 @@
; RUN: not llc -O0 -march=amdgcn -mcpu=bonaire -mattr=-promote-alloca < %s 2>&1 | FileCheck -check-prefix=ERROR %s
-; ERROR: unsupported addrspacecast not implemented
+; ERROR: addrspacecast not implemented
; XUN: llc -O0 -march=amdgcn -mcpu=bonaire -mattr=-promote-alloca < %s | FileCheck -check-prefix=CHECK -check-prefix=CHECK-NO-PROMOTE %s
; XUN: llc -O0 -march=amdgcn -mcpu=bonaire -mattr=+promote-alloca < %s | FileCheck -check-prefix=CHECK -check-prefix=CHECK-PROMOTE %s
Modified: llvm/trunk/test/CodeGen/AMDGPU/call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/call.ll?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/call.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/call.ll Tue Feb 2 07:52:43 2016
@@ -2,7 +2,7 @@
; RUN: not llc -march=amdgcn -mcpu=tonga -verify-machineinstrs< %s 2>&1 | FileCheck %s
; RUN: not llc -march=r600 -mcpu=cypress < %s 2>&1 | FileCheck %s
-; CHECK: error: unsupported call to function external_function in test_call_external
+; CHECK: in function test_call_external{{.*}}: unsupported call to function external_function
declare i32 @external_function(i32) nounwind
Modified: llvm/trunk/test/CodeGen/AMDGPU/dynamic_stackalloc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/dynamic_stackalloc.ll?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/dynamic_stackalloc.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/dynamic_stackalloc.ll Tue Feb 2 07:52:43 2016
@@ -2,7 +2,7 @@
; RUN: not llc -march=amdgcn -mcpu=tahiti -mattr=-promote-alloca -verify-machineinstrs < %s 2>&1 | FileCheck %s
; RUN: not llc -march=r600 -mcpu=cypress < %s 2>&1 | FileCheck %s
-; CHECK: error: unsupported dynamic alloca in test_dynamic_stackalloc
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
define void @test_dynamic_stackalloc(i32 addrspace(1)* %out, i32 %n) {
%alloca = alloca i32, i32 %n
Modified: llvm/trunk/test/CodeGen/AMDGPU/global-zero-initializer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/global-zero-initializer.ll?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/global-zero-initializer.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/global-zero-initializer.ll Tue Feb 2 07:52:43 2016
@@ -1,7 +1,7 @@
; RUN: not llc -march=amdgcn -mcpu=SI < %s 2>&1 | FileCheck %s
; RUN: not llc -march=amdgcn -mcpu=tonga < %s 2>&1 | FileCheck %s
-; CHECK: error: unsupported initializer for address space in load_init_global_global
+; CHECK: in function load_init_global_global{{.*}}: unsupported initializer for address space
@lds = addrspace(1) global [256 x i32] zeroinitializer
Modified: llvm/trunk/test/CodeGen/AMDGPU/lds-initializer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/lds-initializer.ll?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/lds-initializer.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/lds-initializer.ll Tue Feb 2 07:52:43 2016
@@ -1,7 +1,7 @@
; RUN: not llc -march=amdgcn -mcpu=SI < %s 2>&1 | FileCheck %s
; RUN: not llc -march=amdgcn -mcpu=tonga < %s 2>&1 | FileCheck %s
-; CHECK: error: unsupported initializer for address space in load_init_lds_global
+; CHECK: in function load_init_lds_global{{.*}}: unsupported initializer for address space
@lds = addrspace(3) global [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8]
Modified: llvm/trunk/test/CodeGen/AMDGPU/lds-zero-initializer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/lds-zero-initializer.ll?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/lds-zero-initializer.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/lds-zero-initializer.ll Tue Feb 2 07:52:43 2016
@@ -1,7 +1,7 @@
; RUN: not llc -march=amdgcn -mcpu=SI < %s 2>&1 | FileCheck %s
; RUN: not llc -march=amdgcn -mcpu=tonga < %s 2>&1 | FileCheck %s
-; CHECK: error: unsupported initializer for address space in load_zeroinit_lds_global
+; CHECK: in function load_zeroinit_lds_global{{.*}}: unsupported initializer for address space
@lds = addrspace(3) global [256 x i32] zeroinitializer
Modified: llvm/trunk/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll Tue Feb 2 07:52:43 2016
@@ -1,7 +1,7 @@
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
; RUN: not llc -mtriple=amdgcn-unknown-unknown -mcpu=kaveri -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=ERROR %s
-; ERROR: error: unsupported hsa intrinsic without hsa target in test
+; ERROR: in function test{{.*}}: unsupported hsa intrinsic without hsa target
; GCN-LABEL: {{^}}test:
; GCN: enable_sgpr_dispatch_ptr = 1
Modified: llvm/trunk/test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll Tue Feb 2 07:52:43 2016
@@ -1,6 +1,6 @@
; RUN: not llc -march=amdgcn -mtriple=amdgcn-unknown-amdhsa < %s 2>&1 | FileCheck %s
-; CHECK: error: unsupported non-compute shaders with HSA in pixel_shader
+; CHECK: in function pixel_s{{.*}}: unsupported non-compute shaders with HSA
define void @pixel_shader() #0 {
ret void
}
Modified: llvm/trunk/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll?rev=259498&r1=259497&r2=259498&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll Tue Feb 2 07:52:43 2016
@@ -6,7 +6,7 @@
declare void @foo(float*) #0
declare void @foo.varargs(...) #0
-; CHECK: error: unsupported call to function foo in crash_call_constexpr_cast
+; CHECK: in function crash_call_constexpr_cast{{.*}}: unsupported call to function foo
define void @crash_call_constexpr_cast() #0 {
%alloca = alloca i32
call void bitcast (void (float*)* @foo to void (i32*)*)(i32* %alloca) #0
More information about the llvm-commits
mailing list