Skip to content

Commit

Permalink
Revert r259035, it introduces a cyclic library dependency
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259045 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ostannard committed Jan 28, 2016
1 parent 39f8bee commit b95072e
Show file tree
Hide file tree
Showing 22 changed files with 246 additions and 167 deletions.
55 changes: 0 additions & 55 deletions include/llvm/CodeGen/DiagnosticInfoCodeGen.h

This file was deleted.

61 changes: 23 additions & 38 deletions include/llvm/IR/DiagnosticInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ enum DiagnosticKind {
DK_OptimizationFailure,
DK_MIRParser,
DK_PGOProfile,
DK_Unsupported,
DK_FirstPluginKind
};

Expand Down Expand Up @@ -276,42 +275,8 @@ class DiagnosticInfoPGOProfile : public DiagnosticInfo {
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 DiagnosticInfoWithDebugLocBase {
class DiagnosticInfoOptimizationBase : public DiagnosticInfo {
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
Expand All @@ -324,8 +289,8 @@ class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithDebugLocBase {
enum DiagnosticSeverity Severity,
const char *PassName, const Function &Fn,
const DebugLoc &DLoc, const Twine &Msg)
: DiagnosticInfoWithDebugLocBase(Kind, Severity, Fn, DLoc),
PassName(PassName), Msg(Msg) {}
: DiagnosticInfo(Kind, Severity), PassName(PassName), Fn(Fn), DLoc(DLoc),
Msg(Msg) {}

/// \see DiagnosticInfo::print.
void print(DiagnosticPrinter &DP) const override;
Expand All @@ -337,7 +302,21 @@ class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithDebugLocBase {
/// 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:
Expand All @@ -346,6 +325,12 @@ class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithDebugLocBase {
/// 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;
};
Expand Down
1 change: 0 additions & 1 deletion lib/CodeGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ add_llvm_library(LLVMCodeGen
CriticalAntiDepBreaker.cpp
DeadMachineInstructionElim.cpp
DFAPacketizer.cpp
DiagnosticInfoCodeGen.cpp
DwarfEHPrepare.cpp
EarlyIfConversion.cpp
EdgeBundles.cpp
Expand Down
33 changes: 0 additions & 33 deletions lib/CodeGen/DiagnosticInfoCodeGen.cpp

This file was deleted.

6 changes: 3 additions & 3 deletions lib/IR/DiagnosticInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ void DiagnosticInfoPGOProfile::print(DiagnosticPrinter &DP) const {
DP << getMsg();
}

bool DiagnosticInfoWithDebugLocBase::isLocationAvailable() const {
bool DiagnosticInfoOptimizationBase::isLocationAvailable() const {
return getDebugLoc();
}

void DiagnosticInfoWithDebugLocBase::getLocation(StringRef *Filename,
void DiagnosticInfoOptimizationBase::getLocation(StringRef *Filename,
unsigned *Line,
unsigned *Column) const {
DILocation *L = getDebugLoc();
Expand All @@ -152,7 +152,7 @@ void DiagnosticInfoWithDebugLocBase::getLocation(StringRef *Filename,
*Column = L->getColumn();
}

const std::string DiagnosticInfoWithDebugLocBase::getLocationStr() const {
const std::string DiagnosticInfoOptimizationBase::getLocationStr() const {
StringRef Filename("<unknown>");
unsigned Line = 0;
unsigned Column = 0;
Expand Down
26 changes: 26 additions & 0 deletions lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//===-- 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();
}
48 changes: 48 additions & 0 deletions lib/Target/AMDGPU/AMDGPUDiagnosticInfoUnsupported.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//===-- 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
4 changes: 2 additions & 2 deletions lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//

#include "AMDGPUDiagnosticInfoUnsupported.h"
#include "AMDGPUInstrInfo.h"
#include "AMDGPUISelLowering.h" // For AMDGPUISD
#include "AMDGPURegisterInfo.h"
Expand All @@ -20,7 +21,6 @@
#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"
Expand Down Expand Up @@ -1220,7 +1220,7 @@ SDNode *AMDGPUDAGToDAGISel::SelectAddrSpaceCast(SDNode *N) {

const MachineFunction &MF = CurDAG->getMachineFunction();
DiagnosticInfoUnsupported NotImplemented(*MF.getFunction(),
"addrspacecast not implemented", DL);
"addrspacecast not implemented");
CurDAG->getContext()->diagnose(NotImplemented);

assert(Subtarget->hasFlatAddressSpace() &&
Expand Down
10 changes: 5 additions & 5 deletions lib/Target/AMDGPU/AMDGPUISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

#include "AMDGPUISelLowering.h"
#include "AMDGPU.h"
#include "AMDGPUDiagnosticInfoUnsupported.h"
#include "AMDGPUFrameLowering.h"
#include "AMDGPUIntrinsicInfo.h"
#include "AMDGPURegisterInfo.h"
#include "AMDGPUSubtarget.h"
#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"
Expand Down Expand Up @@ -609,7 +609,7 @@ SDValue AMDGPUTargetLowering::LowerCall(CallLoweringInfo &CLI,
else if (const GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
FuncName = G->getGlobal()->getName();

DiagnosticInfoUnsupported NoCalls(Fn, "unsupported call to function " + FuncName, CLI.DL);
DiagnosticInfoUnsupported NoCalls(Fn, "call to function " + FuncName);
DAG.getContext()->diagnose(NoCalls);
return SDValue();
}
Expand All @@ -618,7 +618,7 @@ SDValue AMDGPUTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
SelectionDAG &DAG) const {
const Function &Fn = *DAG.getMachineFunction().getFunction();

DiagnosticInfoUnsupported NoDynamicAlloca(Fn, "unsupported dynamic alloca", SDLoc(Op));
DiagnosticInfoUnsupported NoDynamicAlloca(Fn, "dynamic alloca");
DAG.getContext()->diagnose(NoDynamicAlloca);
return SDValue();
}
Expand Down Expand Up @@ -865,8 +865,8 @@ SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI,
}

const Function &Fn = *DAG.getMachineFunction().getFunction();
DiagnosticInfoUnsupported BadInit(
Fn, "unsupported initializer for address space", SDLoc(Op));
DiagnosticInfoUnsupported BadInit(Fn,
"initializer for address space");
DAG.getContext()->diagnose(BadInit);
return SDValue();
}
Expand Down
1 change: 1 addition & 0 deletions lib/Target/AMDGPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_llvm_target(AMDGPUCodeGen
AMDGPUAnnotateKernelFeatures.cpp
AMDGPUAnnotateUniformValues.cpp
AMDGPUAsmPrinter.cpp
AMDGPUDiagnosticInfoUnsupported.cpp
AMDGPUFrameLowering.cpp
AMDGPUTargetObjectFile.cpp
AMDGPUIntrinsicInfo.cpp
Expand Down
Loading

0 comments on commit b95072e

Please sign in to comment.