Warn on misuse of DiagnosticInfo classes that hold Twines (#137397)
This annotates the `Twine` passed to the constructors of the various DiagnosticInfo subclasses with `[[clang::lifetimebound]]`, which causes us to warn when we would try to print the twine after it had already been destructed. We also update `DiagnosticInfoUnsupported` to hold a `const Twine &` like all of the other DiagnosticInfo classes, since this warning allows us to clean up all of the places where it was being used incorrectly.
This commit is contained in:
parent
e653dc9ca0
commit
b7bb256703
@ -146,11 +146,12 @@ public:
|
||||
/// \p MsgStr is the message to be reported to the frontend.
|
||||
/// This class does not copy \p MsgStr, therefore the reference must be valid
|
||||
/// for the whole life time of the Diagnostic.
|
||||
DiagnosticInfoGeneric(const Twine &MsgStr,
|
||||
DiagnosticInfoGeneric(const Twine &MsgStr LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_Generic, Severity), MsgStr(MsgStr) {}
|
||||
|
||||
DiagnosticInfoGeneric(const Instruction *I, const Twine &ErrMsg,
|
||||
DiagnosticInfoGeneric(const Instruction *I,
|
||||
const Twine &ErrMsg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_Generic, Severity), MsgStr(ErrMsg), Inst(I) {}
|
||||
|
||||
@ -181,7 +182,8 @@ public:
|
||||
/// \p MsgStr gives the message.
|
||||
/// This class does not copy \p MsgStr, therefore the reference must be valid
|
||||
/// for the whole life time of the Diagnostic.
|
||||
DiagnosticInfoInlineAsm(uint64_t LocCookie, const Twine &MsgStr,
|
||||
DiagnosticInfoInlineAsm(uint64_t LocCookie,
|
||||
const Twine &MsgStr LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error);
|
||||
|
||||
/// \p Instr gives the original instruction that triggered the diagnostic.
|
||||
@ -189,7 +191,8 @@ public:
|
||||
/// This class does not copy \p MsgStr, therefore the reference must be valid
|
||||
/// for the whole life time of the Diagnostic.
|
||||
/// Same for \p I.
|
||||
DiagnosticInfoInlineAsm(const Instruction &I, const Twine &MsgStr,
|
||||
DiagnosticInfoInlineAsm(const Instruction &I,
|
||||
const Twine &MsgStr LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error);
|
||||
|
||||
uint64_t getLocCookie() const { return LocCookie; }
|
||||
@ -258,15 +261,16 @@ public:
|
||||
class DiagnosticInfoSampleProfile : public DiagnosticInfo {
|
||||
public:
|
||||
DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum,
|
||||
const Twine &Msg,
|
||||
const Twine &Msg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
|
||||
LineNum(LineNum), Msg(Msg) {}
|
||||
DiagnosticInfoSampleProfile(StringRef FileName, const Twine &Msg,
|
||||
DiagnosticInfoSampleProfile(StringRef FileName,
|
||||
const Twine &Msg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
|
||||
Msg(Msg) {}
|
||||
DiagnosticInfoSampleProfile(const Twine &Msg,
|
||||
DiagnosticInfoSampleProfile(const Twine &Msg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_SampleProfile, Severity), Msg(Msg) {}
|
||||
|
||||
@ -296,7 +300,8 @@ private:
|
||||
/// Diagnostic information for the PGO profiler.
|
||||
class DiagnosticInfoPGOProfile : public DiagnosticInfo {
|
||||
public:
|
||||
DiagnosticInfoPGOProfile(const char *FileName, const Twine &Msg,
|
||||
DiagnosticInfoPGOProfile(const char *FileName,
|
||||
const Twine &Msg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_PGOProfile, Severity), FileName(FileName), Msg(Msg) {}
|
||||
|
||||
@ -364,7 +369,7 @@ public:
|
||||
|
||||
/// Return the absolute path tot the file.
|
||||
std::string getAbsolutePath() const;
|
||||
|
||||
|
||||
const Function &getFunction() const { return Fn; }
|
||||
DiagnosticLocation getLocation() const { return Loc; }
|
||||
|
||||
@ -1062,7 +1067,7 @@ public:
|
||||
/// Diagnostic information for unsupported feature in backend.
|
||||
class DiagnosticInfoUnsupported : public DiagnosticInfoWithLocationBase {
|
||||
private:
|
||||
Twine Msg;
|
||||
const Twine &Msg;
|
||||
|
||||
public:
|
||||
/// \p Fn is the function where the diagnostic is being emitted. \p Loc is
|
||||
@ -1072,7 +1077,7 @@ public:
|
||||
/// copy this message, so this reference must be valid for the whole life time
|
||||
/// of the diagnostic.
|
||||
DiagnosticInfoUnsupported(
|
||||
const Function &Fn, const Twine &Msg,
|
||||
const Function &Fn, const Twine &Msg LLVM_LIFETIME_BOUND,
|
||||
const DiagnosticLocation &Loc = DiagnosticLocation(),
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfoWithLocationBase(DK_Unsupported, Severity, Fn, Loc),
|
||||
@ -1090,7 +1095,8 @@ public:
|
||||
/// Diagnostic information for MisExpect analysis.
|
||||
class DiagnosticInfoMisExpect : public DiagnosticInfoWithLocationBase {
|
||||
public:
|
||||
DiagnosticInfoMisExpect(const Instruction *Inst, const Twine &Msg);
|
||||
DiagnosticInfoMisExpect(const Instruction *Inst,
|
||||
const Twine &Msg LLVM_LIFETIME_BOUND);
|
||||
|
||||
/// \see DiagnosticInfo::print.
|
||||
void print(DiagnosticPrinter &DP) const override;
|
||||
|
@ -709,7 +709,7 @@ class LoweringDiagnosticInfo : public DiagnosticInfo {
|
||||
const Twine &Msg;
|
||||
|
||||
public:
|
||||
LoweringDiagnosticInfo(const Twine &DiagMsg,
|
||||
LoweringDiagnosticInfo(const Twine &DiagMsg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_Lowering, Severity), Msg(DiagMsg) {}
|
||||
void print(DiagnosticPrinter &DP) const override { DP << Msg; }
|
||||
|
@ -739,7 +739,8 @@ namespace {
|
||||
class LTODiagnosticInfo : public DiagnosticInfo {
|
||||
const Twine &Msg;
|
||||
public:
|
||||
LTODiagnosticInfo(const Twine &DiagMsg, DiagnosticSeverity Severity=DS_Error)
|
||||
LTODiagnosticInfo(const Twine &DiagMsg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
|
||||
void print(DiagnosticPrinter &DP) const override { DP << Msg; }
|
||||
};
|
||||
|
@ -163,7 +163,7 @@ namespace {
|
||||
class ThinLTODiagnosticInfo : public DiagnosticInfo {
|
||||
const Twine &Msg;
|
||||
public:
|
||||
ThinLTODiagnosticInfo(const Twine &DiagMsg,
|
||||
ThinLTODiagnosticInfo(const Twine &DiagMsg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
|
||||
void print(DiagnosticPrinter &DP) const override { DP << Msg; }
|
||||
|
@ -16,7 +16,8 @@ class LinkDiagnosticInfo : public DiagnosticInfo {
|
||||
const Twine &Msg;
|
||||
|
||||
public:
|
||||
LinkDiagnosticInfo(DiagnosticSeverity Severity, const Twine &Msg);
|
||||
LinkDiagnosticInfo(DiagnosticSeverity Severity,
|
||||
const Twine &Msg LLVM_LIFETIME_BOUND);
|
||||
void print(DiagnosticPrinter &DP) const override;
|
||||
};
|
||||
}
|
||||
|
@ -1389,9 +1389,8 @@ SDValue AMDGPUTargetLowering::lowerUnhandledCall(CallLoweringInfo &CLI,
|
||||
else if (const GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
|
||||
FuncName = G->getGlobal()->getName();
|
||||
|
||||
DiagnosticInfoUnsupported NoCalls(
|
||||
Fn, Reason + FuncName, CLI.DL.getDebugLoc());
|
||||
DAG.getContext()->diagnose(NoCalls);
|
||||
DAG.getContext()->diagnose(
|
||||
DiagnosticInfoUnsupported(Fn, Reason + FuncName, CLI.DL.getDebugLoc()));
|
||||
|
||||
if (!CLI.IsTailCall) {
|
||||
for (ISD::InputArg &Arg : CLI.Ins)
|
||||
@ -1410,9 +1409,8 @@ SDValue AMDGPUTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
|
||||
SelectionDAG &DAG) const {
|
||||
const Function &Fn = DAG.getMachineFunction().getFunction();
|
||||
|
||||
DiagnosticInfoUnsupported NoDynamicAlloca(Fn, "unsupported dynamic alloca",
|
||||
SDLoc(Op).getDebugLoc());
|
||||
DAG.getContext()->diagnose(NoDynamicAlloca);
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
Fn, "unsupported dynamic alloca", SDLoc(Op).getDebugLoc()));
|
||||
auto Ops = {DAG.getConstant(0, SDLoc(), Op.getValueType()), Op.getOperand(0)};
|
||||
return DAG.getMergeValues(Ops, SDLoc());
|
||||
}
|
||||
@ -1527,10 +1525,9 @@ SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI,
|
||||
!AMDGPU::isNamedBarrier(*cast<GlobalVariable>(GV))) {
|
||||
SDLoc DL(Op);
|
||||
const Function &Fn = DAG.getMachineFunction().getFunction();
|
||||
DiagnosticInfoUnsupported BadLDSDecl(
|
||||
Fn, "local memory global used by non-kernel function",
|
||||
DL.getDebugLoc(), DS_Warning);
|
||||
DAG.getContext()->diagnose(BadLDSDecl);
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
Fn, "local memory global used by non-kernel function",
|
||||
DL.getDebugLoc(), DS_Warning));
|
||||
|
||||
// We currently don't have a way to correctly allocate LDS objects that
|
||||
// aren't directly associated with a kernel. We do force inlining of
|
||||
|
@ -2339,9 +2339,9 @@ bool AMDGPUInstructionSelector::selectG_INTRINSIC_W_SIDE_EFFECTS(
|
||||
case Intrinsic::amdgcn_exp_compr:
|
||||
if (!STI.hasCompressedExport()) {
|
||||
Function &F = I.getMF()->getFunction();
|
||||
DiagnosticInfoUnsupported NoFpRet(
|
||||
F, "intrinsic not supported on subtarget", I.getDebugLoc(), DS_Error);
|
||||
F.getContext().diagnose(NoFpRet);
|
||||
F.getContext().diagnose(
|
||||
DiagnosticInfoUnsupported(F, "intrinsic not supported on subtarget",
|
||||
I.getDebugLoc(), DS_Error));
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -3014,10 +3014,9 @@ bool AMDGPULegalizerInfo::legalizeGlobalValue(
|
||||
GV->getName() != "llvm.amdgcn.module.lds" &&
|
||||
!AMDGPU::isNamedBarrier(*cast<GlobalVariable>(GV))) {
|
||||
const Function &Fn = MF.getFunction();
|
||||
DiagnosticInfoUnsupported BadLDSDecl(
|
||||
Fn, "local memory global used by non-kernel function", MI.getDebugLoc(),
|
||||
DS_Warning);
|
||||
Fn.getContext().diagnose(BadLDSDecl);
|
||||
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
|
||||
Fn, "local memory global used by non-kernel function",
|
||||
MI.getDebugLoc(), DS_Warning));
|
||||
|
||||
// We currently don't have a way to correctly allocate LDS objects that
|
||||
// aren't directly associated with a kernel. We do force inlining of
|
||||
@ -7046,11 +7045,9 @@ bool AMDGPULegalizerInfo::legalizeDebugTrap(MachineInstr &MI,
|
||||
// accordingly
|
||||
if (!ST.isTrapHandlerEnabled() ||
|
||||
ST.getTrapHandlerAbi() != GCNSubtarget::TrapHandlerAbi::AMDHSA) {
|
||||
DiagnosticInfoUnsupported NoTrap(B.getMF().getFunction(),
|
||||
"debugtrap handler not supported",
|
||||
MI.getDebugLoc(), DS_Warning);
|
||||
LLVMContext &Ctx = B.getMF().getFunction().getContext();
|
||||
Ctx.diagnose(NoTrap);
|
||||
Function &Fn = B.getMF().getFunction();
|
||||
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
|
||||
Fn, "debugtrap handler not supported", MI.getDebugLoc(), DS_Warning));
|
||||
} else {
|
||||
// Insert debug-trap instruction
|
||||
B.buildInstr(AMDGPU::S_TRAP)
|
||||
@ -7078,10 +7075,9 @@ bool AMDGPULegalizerInfo::legalizeBVHIntersectRayIntrinsic(
|
||||
Register TDescr = MI.getOperand(7).getReg();
|
||||
|
||||
if (!ST.hasGFX10_AEncoding()) {
|
||||
DiagnosticInfoUnsupported BadIntrin(B.getMF().getFunction(),
|
||||
"intrinsic not supported on subtarget",
|
||||
MI.getDebugLoc());
|
||||
B.getMF().getFunction().getContext().diagnose(BadIntrin);
|
||||
Function &Fn = B.getMF().getFunction();
|
||||
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
|
||||
Fn, "intrinsic not supported on subtarget", MI.getDebugLoc()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -7231,10 +7227,9 @@ bool AMDGPULegalizerInfo::legalizeBVHDualOrBVH8IntersectRayIntrinsic(
|
||||
Register TDescr = MI.getOperand(10).getReg();
|
||||
|
||||
if (!ST.hasBVHDualAndBVH8Insts()) {
|
||||
DiagnosticInfoUnsupported BadIntrin(B.getMF().getFunction(),
|
||||
"intrinsic not supported on subtarget",
|
||||
MI.getDebugLoc());
|
||||
B.getMF().getFunction().getContext().diagnose(BadIntrin);
|
||||
Function &Fn = B.getMF().getFunction();
|
||||
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
|
||||
Fn, "intrinsic not supported on subtarget", MI.getDebugLoc()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -128,12 +128,11 @@ static StringRef getAsConstantStr(Value *V) {
|
||||
}
|
||||
|
||||
static void diagnoseInvalidFormatString(const CallBase *CI) {
|
||||
DiagnosticInfoUnsupported UnsupportedFormatStr(
|
||||
CI->getContext().diagnose(DiagnosticInfoUnsupported(
|
||||
*CI->getParent()->getParent(),
|
||||
"printf format string must be a trivially resolved constant string "
|
||||
"global variable",
|
||||
CI->getDebugLoc());
|
||||
CI->getContext().diagnose(UnsupportedFormatStr);
|
||||
CI->getDebugLoc()));
|
||||
}
|
||||
|
||||
bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
|
||||
|
@ -2860,9 +2860,8 @@ SDValue SITargetLowering::LowerFormalArguments(
|
||||
bool IsError = false;
|
||||
|
||||
if (Subtarget->isAmdHsaOS() && AMDGPU::isGraphics(CallConv)) {
|
||||
DiagnosticInfoUnsupported NoGraphicsHSA(
|
||||
Fn, "unsupported non-compute shaders with HSA", DL.getDebugLoc());
|
||||
DAG.getContext()->diagnose(NoGraphicsHSA);
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
Fn, "unsupported non-compute shaders with HSA", DL.getDebugLoc()));
|
||||
IsError = true;
|
||||
}
|
||||
|
||||
@ -3086,11 +3085,10 @@ SDValue SITargetLowering::LowerFormalArguments(
|
||||
if (Arg.isOrigArg()) {
|
||||
Argument *OrigArg = Fn.getArg(Arg.getOrigArgIndex());
|
||||
if (OrigArg->hasAttribute("amdgpu-hidden-argument")) {
|
||||
DiagnosticInfoUnsupported NonPreloadHiddenArg(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
*OrigArg->getParent(),
|
||||
"hidden argument in kernel signature was not preloaded",
|
||||
DL.getDebugLoc());
|
||||
DAG.getContext()->diagnose(NonPreloadHiddenArg);
|
||||
DL.getDebugLoc()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -7315,11 +7313,10 @@ SDValue SITargetLowering::lowerDEBUGTRAP(SDValue Op, SelectionDAG &DAG) const {
|
||||
|
||||
if (!Subtarget->isTrapHandlerEnabled() ||
|
||||
Subtarget->getTrapHandlerAbi() != GCNSubtarget::TrapHandlerAbi::AMDHSA) {
|
||||
DiagnosticInfoUnsupported NoTrap(MF.getFunction(),
|
||||
"debugtrap handler not supported",
|
||||
Op.getDebugLoc(), DS_Warning);
|
||||
LLVMContext &Ctx = MF.getFunction().getContext();
|
||||
Ctx.diagnose(NoTrap);
|
||||
Ctx.diagnose(DiagnosticInfoUnsupported(MF.getFunction(),
|
||||
"debugtrap handler not supported",
|
||||
Op.getDebugLoc(), DS_Warning));
|
||||
return Chain;
|
||||
}
|
||||
|
||||
@ -8092,19 +8089,17 @@ SDValue SITargetLowering::lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op,
|
||||
|
||||
static SDValue emitNonHSAIntrinsicError(SelectionDAG &DAG, const SDLoc &DL,
|
||||
EVT VT) {
|
||||
DiagnosticInfoUnsupported BadIntrin(DAG.getMachineFunction().getFunction(),
|
||||
"non-hsa intrinsic with hsa target",
|
||||
DL.getDebugLoc());
|
||||
DAG.getContext()->diagnose(BadIntrin);
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
DAG.getMachineFunction().getFunction(),
|
||||
"non-hsa intrinsic with hsa target", DL.getDebugLoc()));
|
||||
return DAG.getPOISON(VT);
|
||||
}
|
||||
|
||||
static SDValue emitRemovedIntrinsicError(SelectionDAG &DAG, const SDLoc &DL,
|
||||
EVT VT) {
|
||||
DiagnosticInfoUnsupported BadIntrin(DAG.getMachineFunction().getFunction(),
|
||||
"intrinsic not supported on subtarget",
|
||||
DL.getDebugLoc());
|
||||
DAG.getContext()->diagnose(BadIntrin);
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
DAG.getMachineFunction().getFunction(),
|
||||
"intrinsic not supported on subtarget", DL.getDebugLoc()));
|
||||
return DAG.getPOISON(VT);
|
||||
}
|
||||
|
||||
@ -8813,10 +8808,9 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
|
||||
case Intrinsic::amdgcn_dispatch_ptr:
|
||||
case Intrinsic::amdgcn_queue_ptr: {
|
||||
if (!Subtarget->isAmdHsaOrMesa(MF.getFunction())) {
|
||||
DiagnosticInfoUnsupported BadIntrin(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
MF.getFunction(), "unsupported hsa intrinsic without hsa target",
|
||||
DL.getDebugLoc());
|
||||
DAG.getContext()->diagnose(BadIntrin);
|
||||
DL.getDebugLoc()));
|
||||
return DAG.getPOISON(VT);
|
||||
}
|
||||
|
||||
@ -9925,10 +9919,9 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
|
||||
switch (IntrinsicID) {
|
||||
case Intrinsic::amdgcn_exp_compr: {
|
||||
if (!Subtarget->hasCompressedExport()) {
|
||||
DiagnosticInfoUnsupported BadIntrin(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
DAG.getMachineFunction().getFunction(),
|
||||
"intrinsic not supported on subtarget", DL.getDebugLoc());
|
||||
DAG.getContext()->diagnose(BadIntrin);
|
||||
"intrinsic not supported on subtarget", DL.getDebugLoc()));
|
||||
}
|
||||
SDValue Src0 = Op.getOperand(4);
|
||||
SDValue Src1 = Op.getOperand(5);
|
||||
|
@ -623,12 +623,12 @@ static void reportIllegalCopy(const SIInstrInfo *TII, MachineBasicBlock &MBB,
|
||||
MCRegister SrcReg, bool KillSrc,
|
||||
const char *Msg = "illegal VGPR to SGPR copy") {
|
||||
MachineFunction *MF = MBB.getParent();
|
||||
DiagnosticInfoUnsupported IllegalCopy(MF->getFunction(), Msg, DL, DS_Error);
|
||||
|
||||
LLVMContext &C = MF->getFunction().getContext();
|
||||
C.diagnose(IllegalCopy);
|
||||
C.diagnose(DiagnosticInfoUnsupported(MF->getFunction(), Msg, DL, DS_Error));
|
||||
|
||||
BuildMI(MBB, MI, DL, TII->get(AMDGPU::SI_ILLEGAL_COPY), DestReg)
|
||||
.addReg(SrcReg, getKillRegState(KillSrc));
|
||||
.addReg(SrcReg, getKillRegState(KillSrc));
|
||||
}
|
||||
|
||||
/// Handle copying from SGPR to AGPR, or from AGPR to AGPR on GFX908. It is not
|
||||
|
@ -700,8 +700,8 @@ void diagnoseUnknownMMRAASName(const MachineInstr &MI, StringRef AS) {
|
||||
ListSeparator LS;
|
||||
for (const auto &[Name, Val] : ASNames)
|
||||
OS << LS << '\'' << Name << '\'';
|
||||
DiagnosticInfoUnsupported BadTag(Fn, Str.str(), MI.getDebugLoc(), DS_Warning);
|
||||
Fn.getContext().diagnose(BadTag);
|
||||
Fn.getContext().diagnose(
|
||||
DiagnosticInfoUnsupported(Fn, Str.str(), MI.getDebugLoc(), DS_Warning));
|
||||
}
|
||||
|
||||
/// Reads \p MI's MMRAs to parse the "amdgpu-as" MMRA.
|
||||
@ -734,8 +734,8 @@ static SIAtomicAddrSpace getFenceAddrSpaceMMRA(const MachineInstr &MI,
|
||||
void SIMemOpAccess::reportUnsupported(const MachineBasicBlock::iterator &MI,
|
||||
const char *Msg) const {
|
||||
const Function &Func = MI->getParent()->getParent()->getFunction();
|
||||
DiagnosticInfoUnsupported Diag(Func, Msg, MI->getDebugLoc());
|
||||
Func.getContext().diagnose(Diag);
|
||||
Func.getContext().diagnose(
|
||||
DiagnosticInfoUnsupported(Func, Msg, MI->getDebugLoc()));
|
||||
}
|
||||
|
||||
std::optional<std::tuple<SIAtomicScope, SIAtomicAddrSpace, bool>>
|
||||
|
@ -2941,18 +2941,17 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
||||
assert(!isARMFunc && !isDirect &&
|
||||
"Cannot handle call to ARM function or direct call");
|
||||
if (NumBytes > 0) {
|
||||
DiagnosticInfoUnsupported Diag(DAG.getMachineFunction().getFunction(),
|
||||
"call to non-secure function would "
|
||||
"require passing arguments on stack",
|
||||
dl.getDebugLoc());
|
||||
DAG.getContext()->diagnose(Diag);
|
||||
DAG.getContext()->diagnose(
|
||||
DiagnosticInfoUnsupported(DAG.getMachineFunction().getFunction(),
|
||||
"call to non-secure function would require "
|
||||
"passing arguments on stack",
|
||||
dl.getDebugLoc()));
|
||||
}
|
||||
if (isStructRet) {
|
||||
DiagnosticInfoUnsupported Diag(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
DAG.getMachineFunction().getFunction(),
|
||||
"call to non-secure function would return value through pointer",
|
||||
dl.getDebugLoc());
|
||||
DAG.getContext()->diagnose(Diag);
|
||||
dl.getDebugLoc()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3320,11 +3319,10 @@ ARMTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
|
||||
if (AFI->isCmseNSEntryFunction() && MF.getFunction().hasStructRetAttr()) {
|
||||
// Note: using an empty SDLoc(), as the first line of the function is a
|
||||
// better place to report than the last line.
|
||||
DiagnosticInfoUnsupported Diag(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
DAG.getMachineFunction().getFunction(),
|
||||
"secure entry function would return value through pointer",
|
||||
SDLoc().getDebugLoc());
|
||||
DAG.getContext()->diagnose(Diag);
|
||||
SDLoc().getDebugLoc()));
|
||||
}
|
||||
|
||||
// Copy the result values into the output registers.
|
||||
@ -4810,10 +4808,9 @@ SDValue ARMTargetLowering::LowerFormalArguments(
|
||||
VarArgStyleRegisters(CCInfo, DAG, dl, Chain, CCInfo.getStackSize(),
|
||||
TotalArgRegsSaveSize);
|
||||
if (AFI->isCmseNSEntryFunction()) {
|
||||
DiagnosticInfoUnsupported Diag(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
DAG.getMachineFunction().getFunction(),
|
||||
"secure entry function must not be variadic", dl.getDebugLoc());
|
||||
DAG.getContext()->diagnose(Diag);
|
||||
"secure entry function must not be variadic", dl.getDebugLoc()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4831,10 +4828,9 @@ SDValue ARMTargetLowering::LowerFormalArguments(
|
||||
AFI->setArgumentStackSize(StackArgSize);
|
||||
|
||||
if (CCInfo.getStackSize() > 0 && AFI->isCmseNSEntryFunction()) {
|
||||
DiagnosticInfoUnsupported Diag(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
DAG.getMachineFunction().getFunction(),
|
||||
"secure entry function requires arguments on stack", dl.getDebugLoc());
|
||||
DAG.getContext()->diagnose(Diag);
|
||||
"secure entry function requires arguments on stack", dl.getDebugLoc()));
|
||||
}
|
||||
|
||||
return Chain;
|
||||
|
@ -183,12 +183,11 @@ void ARMAsmPrinter::EmitSled(const MachineInstr &MI, SledKind Kind)
|
||||
const MachineFunction *MF = MI.getParent()->getParent();
|
||||
if (MF->getInfo<ARMFunctionInfo>()->isThumbFunction()) {
|
||||
const Function &Fn = MF->getFunction();
|
||||
DiagnosticInfoUnsupported Unsupported(
|
||||
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
|
||||
Fn,
|
||||
"An attempt to perform XRay instrumentation for a"
|
||||
" Thumb function (not supported). Detected when emitting a sled.",
|
||||
MI.getDebugLoc());
|
||||
Fn.getContext().diagnose(Unsupported);
|
||||
"An attempt to perform XRay instrumentation for a Thumb function (not "
|
||||
"supported). Detected when emitting a sled.",
|
||||
MI.getDebugLoc()));
|
||||
return;
|
||||
}
|
||||
static const int8_t NoopsInSledCount = 6;
|
||||
|
@ -392,15 +392,14 @@ static bool foldGEPChainAsU8Access(SmallVector<GetElementPtrInst *> &GEPs,
|
||||
}
|
||||
|
||||
static void reportNonStaticGEPChain(Instruction *Insn) {
|
||||
auto Msg = DiagnosticInfoUnsupported(
|
||||
Insn->getContext().diagnose(DiagnosticInfoUnsupported(
|
||||
*Insn->getFunction(),
|
||||
Twine("Non-constant offset in access to a field of a type marked "
|
||||
"with preserve_static_offset might be rejected by BPF verifier")
|
||||
.concat(Insn->getDebugLoc()
|
||||
? ""
|
||||
: " (pass -g option to get exact location)"),
|
||||
Insn->getDebugLoc(), DS_Warning);
|
||||
Insn->getContext().diagnose(Msg);
|
||||
Insn->getDebugLoc(), DS_Warning));
|
||||
}
|
||||
|
||||
static bool allZeroIndices(SmallVector<GetElementPtrInst *> &GEPs) {
|
||||
|
@ -69,14 +69,13 @@ static void WarnSize(int Offset, MachineFunction &MF, DebugLoc& DL,
|
||||
}
|
||||
|
||||
const Function &F = MF.getFunction();
|
||||
DiagnosticInfoUnsupported DiagStackSize(
|
||||
F.getContext().diagnose(DiagnosticInfoUnsupported(
|
||||
F,
|
||||
"Looks like the BPF stack limit is exceeded. "
|
||||
"Please move large on stack variables into BPF per-cpu array map. For "
|
||||
"non-kernel uses, the stack can be increased using -mllvm "
|
||||
"-bpf-stack-size.\n",
|
||||
DL);
|
||||
F.getContext().diagnose(DiagStackSize);
|
||||
DL));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ public:
|
||||
|
||||
if (Error E = ReplaceCall(CI)) {
|
||||
std::string Message(toString(std::move(E)));
|
||||
DiagnosticInfoUnsupported Diag(*CI->getFunction(), Message,
|
||||
CI->getDebugLoc());
|
||||
M.getContext().diagnose(Diag);
|
||||
M.getContext().diagnose(DiagnosticInfoUnsupported(
|
||||
*CI->getFunction(), Message, CI->getDebugLoc()));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,8 @@ public:
|
||||
/// \p M is the module for which the diagnostic is being emitted. \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.
|
||||
DiagnosticInfoTranslateMD(const Module &M, const Twine &Msg,
|
||||
DiagnosticInfoTranslateMD(const Module &M,
|
||||
const Twine &Msg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_Unsupported, Severity), Msg(Msg), Mod(M) {}
|
||||
|
||||
|
@ -1996,12 +1996,11 @@ SDValue NVPTXTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
|
||||
if (STI.getPTXVersion() < 73 || STI.getSmVersion() < 52) {
|
||||
const Function &Fn = DAG.getMachineFunction().getFunction();
|
||||
|
||||
DiagnosticInfoUnsupported NoDynamicAlloca(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
Fn,
|
||||
"Support for dynamic alloca introduced in PTX ISA version 7.3 and "
|
||||
"requires target sm_52.",
|
||||
SDLoc(Op).getDebugLoc());
|
||||
DAG.getContext()->diagnose(NoDynamicAlloca);
|
||||
SDLoc(Op).getDebugLoc()));
|
||||
auto Ops = {DAG.getConstant(0, SDLoc(), Op.getValueType()),
|
||||
Op.getOperand(0)};
|
||||
return DAG.getMergeValues(Ops, SDLoc());
|
||||
@ -2037,12 +2036,11 @@ SDValue NVPTXTargetLowering::LowerSTACKRESTORE(SDValue Op,
|
||||
if (STI.getPTXVersion() < 73 || STI.getSmVersion() < 52) {
|
||||
const Function &Fn = DAG.getMachineFunction().getFunction();
|
||||
|
||||
DiagnosticInfoUnsupported NoStackRestore(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
Fn,
|
||||
"Support for stackrestore requires PTX ISA version >= 7.3 and target "
|
||||
">= sm_52.",
|
||||
DL.getDebugLoc());
|
||||
DAG.getContext()->diagnose(NoStackRestore);
|
||||
DL.getDebugLoc()));
|
||||
return Op.getOperand(0);
|
||||
}
|
||||
|
||||
@ -2060,12 +2058,11 @@ SDValue NVPTXTargetLowering::LowerSTACKSAVE(SDValue Op,
|
||||
if (STI.getPTXVersion() < 73 || STI.getSmVersion() < 52) {
|
||||
const Function &Fn = DAG.getMachineFunction().getFunction();
|
||||
|
||||
DiagnosticInfoUnsupported NoStackSave(
|
||||
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
|
||||
Fn,
|
||||
"Support for stacksave requires PTX ISA version >= 7.3 and target >= "
|
||||
"sm_52.",
|
||||
DL.getDebugLoc());
|
||||
DAG.getContext()->diagnose(NoStackSave);
|
||||
DL.getDebugLoc()));
|
||||
auto Ops = {DAG.getConstant(0, DL, Op.getValueType()), Op.getOperand(0)};
|
||||
return DAG.getMergeValues(Ops, DL);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class DiagnosticInfoKCFI : public DiagnosticInfo {
|
||||
const Twine &Msg;
|
||||
|
||||
public:
|
||||
DiagnosticInfoKCFI(const Twine &DiagMsg,
|
||||
DiagnosticInfoKCFI(const Twine &DiagMsg LLVM_LIFETIME_BOUND,
|
||||
DiagnosticSeverity Severity = DS_Error)
|
||||
: DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
|
||||
void print(DiagnosticPrinter &DP) const override { DP << Msg; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user