From b4b092ea1bf6b41012f0d9b98f8d519e9384c109 Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Thu, 28 Jan 2016 10:07:27 +0000 Subject: [PATCH] Add backend dignostic printer for unsupported features Re-commit of r258951 after fixing layering violation. The related LLVM patch adds a backend diagnostic type for reporting unsupported features, this adds a printer for them to clang. In the case where debug location information is not available, I've changed the printer to report the location as the first line of the function, rather than the closing brace, as the latter does not give the user any information. This also affects optimisation remarks. Differential Revision: http://reviews.llvm.org/D16590 llvm-svn: 259035 --- llvm/include/llvm/CodeGen/DiagnosticInfoCodeGen.h | 55 +++++++++++++++ llvm/include/llvm/IR/DiagnosticInfo.h | 61 ++++++++++------ llvm/lib/CodeGen/CMakeLists.txt | 1 + llvm/lib/CodeGen/DiagnosticInfoCodeGen.cpp | 33 +++++++++ llvm/lib/IR/DiagnosticInfo.cpp | 6 +- .../AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp | 26 ------- .../AMDGPU/AMDGPUDiagnosticInfoUnsupported.h | 48 ------------- llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | 4 +- llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp | 10 +-- llvm/lib/Target/AMDGPU/CMakeLists.txt | 1 - llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 10 +-- llvm/lib/Target/BPF/BPFISelLowering.cpp | 81 ++++------------------ .../Target/WebAssembly/WebAssemblyISelLowering.cpp | 57 +-------------- llvm/test/CodeGen/AMDGPU/addrspacecast.ll | 2 +- llvm/test/CodeGen/AMDGPU/call.ll | 2 +- llvm/test/CodeGen/AMDGPU/dynamic_stackalloc.ll | 2 +- .../test/CodeGen/AMDGPU/global-zero-initializer.ll | 2 +- llvm/test/CodeGen/AMDGPU/lds-initializer.ll | 2 +- llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll | 2 +- .../CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll | 2 +- .../test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll | 2 +- .../AMDGPU/promote-alloca-bitcast-function.ll | 2 +- 22 files changed, 166 insertions(+), 245 deletions(-) create mode 100644 llvm/include/llvm/CodeGen/DiagnosticInfoCodeGen.h create mode 100644 llvm/lib/CodeGen/DiagnosticInfoCodeGen.cpp delete mode 100644 llvm/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp delete mode 100644 llvm/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h diff --git a/llvm/include/llvm/CodeGen/DiagnosticInfoCodeGen.h b/llvm/include/llvm/CodeGen/DiagnosticInfoCodeGen.h new file mode 100644 index 0000000..cceb536 --- /dev/null +++ b/llvm/include/llvm/CodeGen/DiagnosticInfoCodeGen.h @@ -0,0 +1,55 @@ +//===- llvm/Support/DiagnosticInfoCodeGen.h - Diagnostic Declaration ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the different classes involved in codegen diagnostics. +// +// Diagnostics reporting is still done as part of the LLVMContext. +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_DIAGNOSTICINFOCODEGEN_H +#define LLVM_CODEGEN_DIAGNOSTICINFOCODEGEN_H + +#include "llvm/CodeGen/SelectionDAG.h" +#include "llvm/IR/DiagnosticInfo.h" +#include "llvm/IR/DiagnosticPrinter.h" + +namespace llvm { + +/// Diagnostic information for unsupported feature in backend. +class DiagnosticInfoUnsupported + : public DiagnosticInfoWithDebugLocBase { +private: + const Twine &Msg; + const SDValue Value; + +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, + SDLoc DLoc = SDLoc(), SDValue Value = SDValue()) + : DiagnosticInfoWithDebugLocBase(DK_Unsupported, DS_Error, Fn, + DLoc.getDebugLoc()), + Msg(Msg), Value(Value) {} + + static bool classof(const DiagnosticInfo *DI) { + return DI->getKind() == DK_Unsupported; + } + + const Twine &getMessage() const { return Msg; } + + void print(DiagnosticPrinter &DP) const; +}; + +} + +#endif diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h index f69955e..1df0d7a 100644 --- a/llvm/include/llvm/IR/DiagnosticInfo.h +++ b/llvm/include/llvm/IR/DiagnosticInfo.h @@ -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 ":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 ":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; }; diff --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt index 8e326fa..b55a475 100644 --- a/llvm/lib/CodeGen/CMakeLists.txt +++ b/llvm/lib/CodeGen/CMakeLists.txt @@ -18,6 +18,7 @@ add_llvm_library(LLVMCodeGen CriticalAntiDepBreaker.cpp DeadMachineInstructionElim.cpp DFAPacketizer.cpp + DiagnosticInfoCodeGen.cpp DwarfEHPrepare.cpp EarlyIfConversion.cpp EdgeBundles.cpp diff --git a/llvm/lib/CodeGen/DiagnosticInfoCodeGen.cpp b/llvm/lib/CodeGen/DiagnosticInfoCodeGen.cpp new file mode 100644 index 0000000..43adc5e --- /dev/null +++ b/llvm/lib/CodeGen/DiagnosticInfoCodeGen.cpp @@ -0,0 +1,33 @@ +//===- llvm/Support/DiagnosticInfoCodeGen.cpp - Diagnostic Definitions -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the different classes involved in codegen diagnostics. +// +// Diagnostics reporting is still done as part of the LLVMContext. +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/DiagnosticInfoCodeGen.h" +#include "llvm/IR/DiagnosticPrinter.h" + +namespace llvm { + +void DiagnosticInfoUnsupported::print(DiagnosticPrinter &DP) const { + std::string Str; + raw_string_ostream OS(Str); + + OS << getLocationStr() << ": in function " << getFunction().getName() << ' ' + << *getFunction().getFunctionType() << ": " << Msg; + if (Value) + Value->print(OS); + OS << '\n'; + OS.flush(); + DP << Str; +} + +} diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index 6426f76..b16c5f3 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -138,11 +138,11 @@ void DiagnosticInfoPGOProfile::print(DiagnosticPrinter &DP) const { 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::getLocation(StringRef *Filename, *Column = L->getColumn(); } -const std::string DiagnosticInfoOptimizationBase::getLocationStr() const { +const std::string DiagnosticInfoWithDebugLocBase::getLocationStr() const { StringRef Filename(""); unsigned Line = 0; unsigned Column = 0; diff --git a/llvm/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp b/llvm/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp deleted file mode 100644 index 2f6b302..0000000 --- a/llvm/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp +++ /dev/null @@ -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(); -} diff --git a/llvm/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h b/llvm/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h deleted file mode 100644 index 0fd37e1..0000000 --- a/llvm/lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h +++ /dev/null @@ -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 diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp index 059f6af..ec8f7f9 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#include "AMDGPUDiagnosticInfoUnsupported.h" #include "AMDGPUInstrInfo.h" #include "AMDGPUISelLowering.h" // For AMDGPUISD #include "AMDGPURegisterInfo.h" @@ -21,6 +20,7 @@ #include "SIDefines.h" #include "SIISelLowering.h" #include "SIMachineFunctionInfo.h" +#include "llvm/CodeGen/DiagnosticInfoCodeGen.h" #include "llvm/CodeGen/FunctionLoweringInfo.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" @@ -1220,7 +1220,7 @@ SDNode *AMDGPUDAGToDAGISel::SelectAddrSpaceCast(SDNode *N) { const MachineFunction &MF = CurDAG->getMachineFunction(); DiagnosticInfoUnsupported NotImplemented(*MF.getFunction(), - "addrspacecast not implemented"); + "addrspacecast not implemented", DL); CurDAG->getContext()->diagnose(NotImplemented); assert(Subtarget->hasFlatAddressSpace() && diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp index 48f61fb..3d25750 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -15,7 +15,6 @@ #include "AMDGPUISelLowering.h" #include "AMDGPU.h" -#include "AMDGPUDiagnosticInfoUnsupported.h" #include "AMDGPUFrameLowering.h" #include "AMDGPUIntrinsicInfo.h" #include "AMDGPURegisterInfo.h" @@ -23,6 +22,7 @@ #include "R600MachineFunctionInfo.h" #include "SIMachineFunctionInfo.h" #include "llvm/CodeGen/CallingConvLower.h" +#include "llvm/CodeGen/DiagnosticInfoCodeGen.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SelectionDAG.h" @@ -609,7 +609,7 @@ SDValue AMDGPUTargetLowering::LowerCall(CallLoweringInfo &CLI, else if (const GlobalAddressSDNode *G = dyn_cast(Callee)) FuncName = G->getGlobal()->getName(); - DiagnosticInfoUnsupported NoCalls(Fn, "call to function " + FuncName); + DiagnosticInfoUnsupported NoCalls(Fn, "unsupported call to function " + FuncName, CLI.DL); DAG.getContext()->diagnose(NoCalls); return SDValue(); } @@ -618,7 +618,7 @@ SDValue AMDGPUTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const { const Function &Fn = *DAG.getMachineFunction().getFunction(); - DiagnosticInfoUnsupported NoDynamicAlloca(Fn, "dynamic alloca"); + DiagnosticInfoUnsupported NoDynamicAlloca(Fn, "unsupported dynamic alloca", SDLoc(Op)); DAG.getContext()->diagnose(NoDynamicAlloca); return SDValue(); } @@ -865,8 +865,8 @@ SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI, } const Function &Fn = *DAG.getMachineFunction().getFunction(); - DiagnosticInfoUnsupported BadInit(Fn, - "initializer for address space"); + DiagnosticInfoUnsupported BadInit( + Fn, "unsupported initializer for address space", SDLoc(Op)); DAG.getContext()->diagnose(BadInit); return SDValue(); } diff --git a/llvm/lib/Target/AMDGPU/CMakeLists.txt b/llvm/lib/Target/AMDGPU/CMakeLists.txt index b9ef0e8..8e99f2b 100644 --- a/llvm/lib/Target/AMDGPU/CMakeLists.txt +++ b/llvm/lib/Target/AMDGPU/CMakeLists.txt @@ -18,7 +18,6 @@ add_llvm_target(AMDGPUCodeGen AMDGPUAnnotateKernelFeatures.cpp AMDGPUAnnotateUniformValues.cpp AMDGPUAsmPrinter.cpp - AMDGPUDiagnosticInfoUnsupported.cpp AMDGPUFrameLowering.cpp AMDGPUTargetObjectFile.cpp AMDGPUIntrinsicInfo.cpp diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index faecf3c..d3201dd 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -20,7 +20,6 @@ #include "SIISelLowering.h" #include "AMDGPU.h" -#include "AMDGPUDiagnosticInfoUnsupported.h" #include "AMDGPUIntrinsicInfo.h" #include "AMDGPUSubtarget.h" #include "SIInstrInfo.h" @@ -29,6 +28,7 @@ #include "llvm/ADT/BitVector.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/CodeGen/CallingConvLower.h" +#include "llvm/CodeGen/DiagnosticInfoCodeGen.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SelectionDAG.h" @@ -591,7 +591,8 @@ SDValue SITargetLowering::LowerFormalArguments( 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); DAG.getContext()->diagnose(NoGraphicsHSA); return SDValue(); } @@ -1320,8 +1321,9 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, 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); DAG.getContext()->diagnose(BadIntrin); return DAG.getUNDEF(VT); } diff --git a/llvm/lib/Target/BPF/BPFISelLowering.cpp b/llvm/lib/Target/BPF/BPFISelLowering.cpp index 6a5b37e..61261c2 100644 --- a/llvm/lib/Target/BPF/BPFISelLowering.cpp +++ b/llvm/lib/Target/BPF/BPFISelLowering.cpp @@ -17,6 +17,7 @@ #include "BPFTargetMachine.h" #include "BPFSubtarget.h" #include "llvm/CodeGen/CallingConvLower.h" +#include "llvm/CodeGen/DiagnosticInfoCodeGen.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" @@ -28,66 +29,10 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/IR/DiagnosticInfo.h" -#include "llvm/IR/DiagnosticPrinter.h" 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(); - } -}; - -int DiagnosticInfoUnsupported::KindID = 0; -} - BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM, const BPFSubtarget &STI) : TargetLowering(TM) { @@ -236,16 +181,16 @@ SDValue BPFTargetLowering::LowerFormalArguments( InVals.push_back(ArgValue); } } else { - DiagnosticInfoUnsupported Err(DL, *MF.getFunction(), - "defined with too many args", SDValue()); + DiagnosticInfoUnsupported Err( + *MF.getFunction(), "defined with too many args", DL); DAG.getContext()->diagnose(Err); } } if (IsVarArg || MF.getFunction()->hasStructRetAttr()) { DiagnosticInfoUnsupported Err( - DL, *MF.getFunction(), - "functions with VarArgs or StructRet are not supported", SDValue()); + *MF.getFunction(), + "functions with VarArgs or StructRet are not supported", DL); DAG.getContext()->diagnose(Err); } @@ -285,8 +230,8 @@ SDValue BPFTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, unsigned NumBytes = CCInfo.getNextStackOffset(); if (Outs.size() >= 6) { - DiagnosticInfoUnsupported Err(CLI.DL, *MF.getFunction(), - "too many args to ", Callee); + DiagnosticInfoUnsupported Err(*MF.getFunction(), "too many args to ", + CLI.DL, Callee); DAG.getContext()->diagnose(Err); } @@ -295,8 +240,8 @@ SDValue BPFTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, if (!Flags.isByVal()) continue; - DiagnosticInfoUnsupported Err(CLI.DL, *MF.getFunction(), - "pass by value not supported ", Callee); + DiagnosticInfoUnsupported Err( + *MF.getFunction(), "pass by value not supported ", CLI.DL, Callee); DAG.getContext()->diagnose(Err); } @@ -398,8 +343,8 @@ BPFTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, *DAG.getContext()); if (MF.getFunction()->getReturnType()->isAggregateType()) { - DiagnosticInfoUnsupported Err(DL, *MF.getFunction(), - "only integer returns supported", SDValue()); + DiagnosticInfoUnsupported Err( + *MF.getFunction(), "only integer returns supported", DL); DAG.getContext()->diagnose(Err); } @@ -443,8 +388,8 @@ SDValue BPFTargetLowering::LowerCallResult( CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, *DAG.getContext()); if (Ins.size() >= 2) { - DiagnosticInfoUnsupported Err(DL, *MF.getFunction(), - "only small returns supported", SDValue()); + DiagnosticInfoUnsupported Err(*MF.getFunction(), + "only small returns supported", DL); DAG.getContext()->diagnose(Err); } diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index 5211fe7..8d909d5 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -19,10 +19,10 @@ #include "WebAssemblyTargetMachine.h" #include "llvm/CodeGen/Analysis.h" #include "llvm/CodeGen/CallingConvLower.h" +#include "llvm/CodeGen/DiagnosticInfoCodeGen.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SelectionDAG.h" -#include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" #include "llvm/IR/Function.h" #include "llvm/IR/Intrinsics.h" @@ -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) { diff --git a/llvm/test/CodeGen/AMDGPU/addrspacecast.ll b/llvm/test/CodeGen/AMDGPU/addrspacecast.ll index 61bcd4b3..e029d91 100644 --- a/llvm/test/CodeGen/AMDGPU/addrspacecast.ll +++ b/llvm/test/CodeGen/AMDGPU/addrspacecast.ll @@ -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 diff --git a/llvm/test/CodeGen/AMDGPU/call.ll b/llvm/test/CodeGen/AMDGPU/call.ll index e769fd1..82e7735 100644 --- a/llvm/test/CodeGen/AMDGPU/call.ll +++ b/llvm/test/CodeGen/AMDGPU/call.ll @@ -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 diff --git a/llvm/test/CodeGen/AMDGPU/dynamic_stackalloc.ll b/llvm/test/CodeGen/AMDGPU/dynamic_stackalloc.ll index f4409a0..580dc00 100644 --- a/llvm/test/CodeGen/AMDGPU/dynamic_stackalloc.ll +++ b/llvm/test/CodeGen/AMDGPU/dynamic_stackalloc.ll @@ -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 diff --git a/llvm/test/CodeGen/AMDGPU/global-zero-initializer.ll b/llvm/test/CodeGen/AMDGPU/global-zero-initializer.ll index 45aa8bf..522a4b2 100644 --- a/llvm/test/CodeGen/AMDGPU/global-zero-initializer.ll +++ b/llvm/test/CodeGen/AMDGPU/global-zero-initializer.ll @@ -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 diff --git a/llvm/test/CodeGen/AMDGPU/lds-initializer.ll b/llvm/test/CodeGen/AMDGPU/lds-initializer.ll index bf8df63..9875814 100644 --- a/llvm/test/CodeGen/AMDGPU/lds-initializer.ll +++ b/llvm/test/CodeGen/AMDGPU/lds-initializer.ll @@ -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] diff --git a/llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll b/llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll index fb51bc0..cb5d73f 100644 --- a/llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll +++ b/llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll @@ -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 diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll index d96ea74..2e86252 100644 --- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll +++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll @@ -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 diff --git a/llvm/test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll b/llvm/test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll index 73a1467..29ef858 100644 --- a/llvm/test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll +++ b/llvm/test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll @@ -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 } diff --git a/llvm/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll b/llvm/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll index 10739df..6090017 100644 --- a/llvm/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll +++ b/llvm/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll @@ -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 -- 2.7.4