Skip to content

Commit acbafa8

Browse files
committed
Warn on misuse of DiagnosticInfo classes that hold Twines
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.
1 parent c4d84e1 commit acbafa8

20 files changed

+105
-122
lines changed

llvm/include/llvm/IR/DiagnosticInfo.h

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ class DiagnosticInfoGeneric : public DiagnosticInfo {
146146
/// \p MsgStr is the message to be reported to the frontend.
147147
/// This class does not copy \p MsgStr, therefore the reference must be valid
148148
/// for the whole life time of the Diagnostic.
149-
DiagnosticInfoGeneric(const Twine &MsgStr,
149+
DiagnosticInfoGeneric(const Twine &MsgStr LLVM_LIFETIME_BOUND,
150150
DiagnosticSeverity Severity = DS_Error)
151151
: DiagnosticInfo(DK_Generic, Severity), MsgStr(MsgStr) {}
152152

153-
DiagnosticInfoGeneric(const Instruction *I, const Twine &ErrMsg,
153+
DiagnosticInfoGeneric(const Instruction *I,
154+
const Twine &ErrMsg LLVM_LIFETIME_BOUND,
154155
DiagnosticSeverity Severity = DS_Error)
155156
: DiagnosticInfo(DK_Generic, Severity), MsgStr(ErrMsg), Inst(I) {}
156157

@@ -181,15 +182,17 @@ class DiagnosticInfoInlineAsm : public DiagnosticInfo {
181182
/// \p MsgStr gives the message.
182183
/// This class does not copy \p MsgStr, therefore the reference must be valid
183184
/// for the whole life time of the Diagnostic.
184-
DiagnosticInfoInlineAsm(uint64_t LocCookie, const Twine &MsgStr,
185+
DiagnosticInfoInlineAsm(uint64_t LocCookie,
186+
const Twine &MsgStr LLVM_LIFETIME_BOUND,
185187
DiagnosticSeverity Severity = DS_Error);
186188

187189
/// \p Instr gives the original instruction that triggered the diagnostic.
188190
/// \p MsgStr gives the message.
189191
/// This class does not copy \p MsgStr, therefore the reference must be valid
190192
/// for the whole life time of the Diagnostic.
191193
/// Same for \p I.
192-
DiagnosticInfoInlineAsm(const Instruction &I, const Twine &MsgStr,
194+
DiagnosticInfoInlineAsm(const Instruction &I,
195+
const Twine &MsgStr LLVM_LIFETIME_BOUND,
193196
DiagnosticSeverity Severity = DS_Error);
194197

195198
uint64_t getLocCookie() const { return LocCookie; }
@@ -258,15 +261,16 @@ class DiagnosticInfoIgnoringInvalidDebugMetadata : public DiagnosticInfo {
258261
class DiagnosticInfoSampleProfile : public DiagnosticInfo {
259262
public:
260263
DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum,
261-
const Twine &Msg,
264+
const Twine &Msg LLVM_LIFETIME_BOUND,
262265
DiagnosticSeverity Severity = DS_Error)
263266
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
264267
LineNum(LineNum), Msg(Msg) {}
265-
DiagnosticInfoSampleProfile(StringRef FileName, const Twine &Msg,
268+
DiagnosticInfoSampleProfile(StringRef FileName,
269+
const Twine &Msg LLVM_LIFETIME_BOUND,
266270
DiagnosticSeverity Severity = DS_Error)
267271
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
268272
Msg(Msg) {}
269-
DiagnosticInfoSampleProfile(const Twine &Msg,
273+
DiagnosticInfoSampleProfile(const Twine &Msg LLVM_LIFETIME_BOUND,
270274
DiagnosticSeverity Severity = DS_Error)
271275
: DiagnosticInfo(DK_SampleProfile, Severity), Msg(Msg) {}
272276

@@ -296,7 +300,8 @@ class DiagnosticInfoSampleProfile : public DiagnosticInfo {
296300
/// Diagnostic information for the PGO profiler.
297301
class DiagnosticInfoPGOProfile : public DiagnosticInfo {
298302
public:
299-
DiagnosticInfoPGOProfile(const char *FileName, const Twine &Msg,
303+
DiagnosticInfoPGOProfile(const char *FileName,
304+
const Twine &Msg LLVM_LIFETIME_BOUND,
300305
DiagnosticSeverity Severity = DS_Error)
301306
: DiagnosticInfo(DK_PGOProfile, Severity), FileName(FileName), Msg(Msg) {}
302307

@@ -364,7 +369,7 @@ class DiagnosticInfoWithLocationBase : public DiagnosticInfo {
364369

365370
/// Return the absolute path tot the file.
366371
std::string getAbsolutePath() const;
367-
372+
368373
const Function &getFunction() const { return Fn; }
369374
DiagnosticLocation getLocation() const { return Loc; }
370375

@@ -1062,7 +1067,7 @@ class DiagnosticInfoOptimizationFailure : public DiagnosticInfoIROptimization {
10621067
/// Diagnostic information for unsupported feature in backend.
10631068
class DiagnosticInfoUnsupported : public DiagnosticInfoWithLocationBase {
10641069
private:
1065-
Twine Msg;
1070+
const Twine &Msg;
10661071

10671072
public:
10681073
/// \p Fn is the function where the diagnostic is being emitted. \p Loc is
@@ -1072,7 +1077,7 @@ class DiagnosticInfoUnsupported : public DiagnosticInfoWithLocationBase {
10721077
/// copy this message, so this reference must be valid for the whole life time
10731078
/// of the diagnostic.
10741079
DiagnosticInfoUnsupported(
1075-
const Function &Fn, const Twine &Msg,
1080+
const Function &Fn, const Twine &Msg LLVM_LIFETIME_BOUND,
10761081
const DiagnosticLocation &Loc = DiagnosticLocation(),
10771082
DiagnosticSeverity Severity = DS_Error)
10781083
: DiagnosticInfoWithLocationBase(DK_Unsupported, Severity, Fn, Loc),
@@ -1090,7 +1095,8 @@ class DiagnosticInfoUnsupported : public DiagnosticInfoWithLocationBase {
10901095
/// Diagnostic information for MisExpect analysis.
10911096
class DiagnosticInfoMisExpect : public DiagnosticInfoWithLocationBase {
10921097
public:
1093-
DiagnosticInfoMisExpect(const Instruction *Inst, const Twine &Msg);
1098+
DiagnosticInfoMisExpect(const Instruction *Inst,
1099+
const Twine &Msg LLVM_LIFETIME_BOUND);
10941100

10951101
/// \see DiagnosticInfo::print.
10961102
void print(DiagnosticPrinter &DP) const override;

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ class LoweringDiagnosticInfo : public DiagnosticInfo {
709709
const Twine &Msg;
710710

711711
public:
712-
LoweringDiagnosticInfo(const Twine &DiagMsg,
712+
LoweringDiagnosticInfo(const Twine &DiagMsg LLVM_LIFETIME_BOUND,
713713
DiagnosticSeverity Severity = DS_Error)
714714
: DiagnosticInfo(DK_Lowering, Severity), Msg(DiagMsg) {}
715715
void print(DiagnosticPrinter &DP) const override { DP << Msg; }

llvm/lib/LTO/LTOCodeGenerator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,8 @@ namespace {
746746
class LTODiagnosticInfo : public DiagnosticInfo {
747747
const Twine &Msg;
748748
public:
749-
LTODiagnosticInfo(const Twine &DiagMsg, DiagnosticSeverity Severity=DS_Error)
749+
LTODiagnosticInfo(const Twine &DiagMsg LLVM_LIFETIME_BOUND,
750+
DiagnosticSeverity Severity = DS_Error)
750751
: DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
751752
void print(DiagnosticPrinter &DP) const override { DP << Msg; }
752753
};

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ namespace {
167167
class ThinLTODiagnosticInfo : public DiagnosticInfo {
168168
const Twine &Msg;
169169
public:
170-
ThinLTODiagnosticInfo(const Twine &DiagMsg,
170+
ThinLTODiagnosticInfo(const Twine &DiagMsg LLVM_LIFETIME_BOUND,
171171
DiagnosticSeverity Severity = DS_Error)
172172
: DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
173173
void print(DiagnosticPrinter &DP) const override { DP << Msg; }

llvm/lib/Linker/LinkDiagnosticInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class LinkDiagnosticInfo : public DiagnosticInfo {
1616
const Twine &Msg;
1717

1818
public:
19-
LinkDiagnosticInfo(DiagnosticSeverity Severity, const Twine &Msg);
19+
LinkDiagnosticInfo(DiagnosticSeverity Severity,
20+
const Twine &Msg LLVM_LIFETIME_BOUND);
2021
void print(DiagnosticPrinter &DP) const override;
2122
};
2223
}

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,9 +1383,8 @@ SDValue AMDGPUTargetLowering::lowerUnhandledCall(CallLoweringInfo &CLI,
13831383
else if (const GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
13841384
FuncName = G->getGlobal()->getName();
13851385

1386-
DiagnosticInfoUnsupported NoCalls(
1387-
Fn, Reason + FuncName, CLI.DL.getDebugLoc());
1388-
DAG.getContext()->diagnose(NoCalls);
1386+
DAG.getContext()->diagnose(
1387+
DiagnosticInfoUnsupported(Fn, Reason + FuncName, CLI.DL.getDebugLoc()));
13891388

13901389
if (!CLI.IsTailCall) {
13911390
for (ISD::InputArg &Arg : CLI.Ins)
@@ -1404,9 +1403,8 @@ SDValue AMDGPUTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
14041403
SelectionDAG &DAG) const {
14051404
const Function &Fn = DAG.getMachineFunction().getFunction();
14061405

1407-
DiagnosticInfoUnsupported NoDynamicAlloca(Fn, "unsupported dynamic alloca",
1408-
SDLoc(Op).getDebugLoc());
1409-
DAG.getContext()->diagnose(NoDynamicAlloca);
1406+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
1407+
Fn, "unsupported dynamic alloca", SDLoc(Op).getDebugLoc()));
14101408
auto Ops = {DAG.getConstant(0, SDLoc(), Op.getValueType()), Op.getOperand(0)};
14111409
return DAG.getMergeValues(Ops, SDLoc());
14121410
}
@@ -1521,10 +1519,9 @@ SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI,
15211519
!AMDGPU::isNamedBarrier(*cast<GlobalVariable>(GV))) {
15221520
SDLoc DL(Op);
15231521
const Function &Fn = DAG.getMachineFunction().getFunction();
1524-
DiagnosticInfoUnsupported BadLDSDecl(
1525-
Fn, "local memory global used by non-kernel function",
1526-
DL.getDebugLoc(), DS_Warning);
1527-
DAG.getContext()->diagnose(BadLDSDecl);
1522+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
1523+
Fn, "local memory global used by non-kernel function",
1524+
DL.getDebugLoc(), DS_Warning));
15281525

15291526
// We currently don't have a way to correctly allocate LDS objects that
15301527
// aren't directly associated with a kernel. We do force inlining of

llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,9 +2340,9 @@ bool AMDGPUInstructionSelector::selectG_INTRINSIC_W_SIDE_EFFECTS(
23402340
case Intrinsic::amdgcn_exp_compr:
23412341
if (!STI.hasCompressedExport()) {
23422342
Function &F = I.getMF()->getFunction();
2343-
DiagnosticInfoUnsupported NoFpRet(
2344-
F, "intrinsic not supported on subtarget", I.getDebugLoc(), DS_Error);
2345-
F.getContext().diagnose(NoFpRet);
2343+
F.getContext().diagnose(
2344+
DiagnosticInfoUnsupported(F, "intrinsic not supported on subtarget",
2345+
I.getDebugLoc(), DS_Error));
23462346
return false;
23472347
}
23482348
break;

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,10 +3005,9 @@ bool AMDGPULegalizerInfo::legalizeGlobalValue(
30053005
GV->getName() != "llvm.amdgcn.module.lds" &&
30063006
!AMDGPU::isNamedBarrier(*cast<GlobalVariable>(GV))) {
30073007
const Function &Fn = MF.getFunction();
3008-
DiagnosticInfoUnsupported BadLDSDecl(
3009-
Fn, "local memory global used by non-kernel function", MI.getDebugLoc(),
3010-
DS_Warning);
3011-
Fn.getContext().diagnose(BadLDSDecl);
3008+
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
3009+
Fn, "local memory global used by non-kernel function",
3010+
MI.getDebugLoc(), DS_Warning));
30123011

30133012
// We currently don't have a way to correctly allocate LDS objects that
30143013
// aren't directly associated with a kernel. We do force inlining of
@@ -7037,11 +7036,9 @@ bool AMDGPULegalizerInfo::legalizeDebugTrap(MachineInstr &MI,
70377036
// accordingly
70387037
if (!ST.isTrapHandlerEnabled() ||
70397038
ST.getTrapHandlerAbi() != GCNSubtarget::TrapHandlerAbi::AMDHSA) {
7040-
DiagnosticInfoUnsupported NoTrap(B.getMF().getFunction(),
7041-
"debugtrap handler not supported",
7042-
MI.getDebugLoc(), DS_Warning);
7043-
LLVMContext &Ctx = B.getMF().getFunction().getContext();
7044-
Ctx.diagnose(NoTrap);
7039+
Function &Fn = B.getMF().getFunction();
7040+
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
7041+
Fn, "debugtrap handler not supported", MI.getDebugLoc(), DS_Warning));
70457042
} else {
70467043
// Insert debug-trap instruction
70477044
B.buildInstr(AMDGPU::S_TRAP)
@@ -7069,10 +7066,9 @@ bool AMDGPULegalizerInfo::legalizeBVHIntersectRayIntrinsic(
70697066
Register TDescr = MI.getOperand(7).getReg();
70707067

70717068
if (!ST.hasGFX10_AEncoding()) {
7072-
DiagnosticInfoUnsupported BadIntrin(B.getMF().getFunction(),
7073-
"intrinsic not supported on subtarget",
7074-
MI.getDebugLoc());
7075-
B.getMF().getFunction().getContext().diagnose(BadIntrin);
7069+
Function &Fn = B.getMF().getFunction();
7070+
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
7071+
Fn, "intrinsic not supported on subtarget", MI.getDebugLoc()));
70767072
return false;
70777073
}
70787074

@@ -7222,10 +7218,9 @@ bool AMDGPULegalizerInfo::legalizeBVHDualOrBVH8IntersectRayIntrinsic(
72227218
Register TDescr = MI.getOperand(10).getReg();
72237219

72247220
if (!ST.hasBVHDualAndBVH8Insts()) {
7225-
DiagnosticInfoUnsupported BadIntrin(B.getMF().getFunction(),
7226-
"intrinsic not supported on subtarget",
7227-
MI.getDebugLoc());
7228-
B.getMF().getFunction().getContext().diagnose(BadIntrin);
7221+
Function &Fn = B.getMF().getFunction();
7222+
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
7223+
Fn, "intrinsic not supported on subtarget", MI.getDebugLoc()));
72297224
return false;
72307225
}
72317226

llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,11 @@ static StringRef getAsConstantStr(Value *V) {
128128
}
129129

130130
static void diagnoseInvalidFormatString(const CallBase *CI) {
131-
DiagnosticInfoUnsupported UnsupportedFormatStr(
131+
CI->getContext().diagnose(DiagnosticInfoUnsupported(
132132
*CI->getParent()->getParent(),
133133
"printf format string must be a trivially resolved constant string "
134134
"global variable",
135-
CI->getDebugLoc());
136-
CI->getContext().diagnose(UnsupportedFormatStr);
135+
CI->getDebugLoc()));
137136
}
138137

139138
bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,9 +2849,8 @@ SDValue SITargetLowering::LowerFormalArguments(
28492849
bool IsError = false;
28502850

28512851
if (Subtarget->isAmdHsaOS() && AMDGPU::isGraphics(CallConv)) {
2852-
DiagnosticInfoUnsupported NoGraphicsHSA(
2853-
Fn, "unsupported non-compute shaders with HSA", DL.getDebugLoc());
2854-
DAG.getContext()->diagnose(NoGraphicsHSA);
2852+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
2853+
Fn, "unsupported non-compute shaders with HSA", DL.getDebugLoc()));
28552854
IsError = true;
28562855
}
28572856

@@ -3075,11 +3074,10 @@ SDValue SITargetLowering::LowerFormalArguments(
30753074
if (Arg.isOrigArg()) {
30763075
Argument *OrigArg = Fn.getArg(Arg.getOrigArgIndex());
30773076
if (OrigArg->hasAttribute("amdgpu-hidden-argument")) {
3078-
DiagnosticInfoUnsupported NonPreloadHiddenArg(
3077+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
30793078
*OrigArg->getParent(),
30803079
"hidden argument in kernel signature was not preloaded",
3081-
DL.getDebugLoc());
3082-
DAG.getContext()->diagnose(NonPreloadHiddenArg);
3080+
DL.getDebugLoc()));
30833081
}
30843082
}
30853083

@@ -7283,11 +7281,10 @@ SDValue SITargetLowering::lowerDEBUGTRAP(SDValue Op, SelectionDAG &DAG) const {
72837281

72847282
if (!Subtarget->isTrapHandlerEnabled() ||
72857283
Subtarget->getTrapHandlerAbi() != GCNSubtarget::TrapHandlerAbi::AMDHSA) {
7286-
DiagnosticInfoUnsupported NoTrap(MF.getFunction(),
7287-
"debugtrap handler not supported",
7288-
Op.getDebugLoc(), DS_Warning);
72897284
LLVMContext &Ctx = MF.getFunction().getContext();
7290-
Ctx.diagnose(NoTrap);
7285+
Ctx.diagnose(DiagnosticInfoUnsupported(MF.getFunction(),
7286+
"debugtrap handler not supported",
7287+
Op.getDebugLoc(), DS_Warning));
72917288
return Chain;
72927289
}
72937290

@@ -8060,19 +8057,17 @@ SDValue SITargetLowering::lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op,
80608057

80618058
static SDValue emitNonHSAIntrinsicError(SelectionDAG &DAG, const SDLoc &DL,
80628059
EVT VT) {
8063-
DiagnosticInfoUnsupported BadIntrin(DAG.getMachineFunction().getFunction(),
8064-
"non-hsa intrinsic with hsa target",
8065-
DL.getDebugLoc());
8066-
DAG.getContext()->diagnose(BadIntrin);
8060+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
8061+
DAG.getMachineFunction().getFunction(),
8062+
"non-hsa intrinsic with hsa target", DL.getDebugLoc()));
80678063
return DAG.getPOISON(VT);
80688064
}
80698065

80708066
static SDValue emitRemovedIntrinsicError(SelectionDAG &DAG, const SDLoc &DL,
80718067
EVT VT) {
8072-
DiagnosticInfoUnsupported BadIntrin(DAG.getMachineFunction().getFunction(),
8073-
"intrinsic not supported on subtarget",
8074-
DL.getDebugLoc());
8075-
DAG.getContext()->diagnose(BadIntrin);
8068+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
8069+
DAG.getMachineFunction().getFunction(),
8070+
"intrinsic not supported on subtarget", DL.getDebugLoc()));
80768071
return DAG.getPOISON(VT);
80778072
}
80788073

@@ -8781,10 +8776,9 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
87818776
case Intrinsic::amdgcn_dispatch_ptr:
87828777
case Intrinsic::amdgcn_queue_ptr: {
87838778
if (!Subtarget->isAmdHsaOrMesa(MF.getFunction())) {
8784-
DiagnosticInfoUnsupported BadIntrin(
8779+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
87858780
MF.getFunction(), "unsupported hsa intrinsic without hsa target",
8786-
DL.getDebugLoc());
8787-
DAG.getContext()->diagnose(BadIntrin);
8781+
DL.getDebugLoc()));
87888782
return DAG.getPOISON(VT);
87898783
}
87908784

@@ -9887,10 +9881,9 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
98879881
switch (IntrinsicID) {
98889882
case Intrinsic::amdgcn_exp_compr: {
98899883
if (!Subtarget->hasCompressedExport()) {
9890-
DiagnosticInfoUnsupported BadIntrin(
9884+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
98919885
DAG.getMachineFunction().getFunction(),
9892-
"intrinsic not supported on subtarget", DL.getDebugLoc());
9893-
DAG.getContext()->diagnose(BadIntrin);
9886+
"intrinsic not supported on subtarget", DL.getDebugLoc()));
98949887
}
98959888
SDValue Src0 = Op.getOperand(4);
98969889
SDValue Src1 = Op.getOperand(5);

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,12 +623,12 @@ static void reportIllegalCopy(const SIInstrInfo *TII, MachineBasicBlock &MBB,
623623
MCRegister SrcReg, bool KillSrc,
624624
const char *Msg = "illegal VGPR to SGPR copy") {
625625
MachineFunction *MF = MBB.getParent();
626-
DiagnosticInfoUnsupported IllegalCopy(MF->getFunction(), Msg, DL, DS_Error);
626+
627627
LLVMContext &C = MF->getFunction().getContext();
628-
C.diagnose(IllegalCopy);
628+
C.diagnose(DiagnosticInfoUnsupported(MF->getFunction(), Msg, DL, DS_Error));
629629

630630
BuildMI(MBB, MI, DL, TII->get(AMDGPU::SI_ILLEGAL_COPY), DestReg)
631-
.addReg(SrcReg, getKillRegState(KillSrc));
631+
.addReg(SrcReg, getKillRegState(KillSrc));
632632
}
633633

634634
/// Handle copying from SGPR to AGPR, or from AGPR to AGPR on GFX908. It is not

llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,8 @@ void diagnoseUnknownMMRAASName(const MachineInstr &MI, StringRef AS) {
700700
ListSeparator LS;
701701
for (const auto &[Name, Val] : ASNames)
702702
OS << LS << '\'' << Name << '\'';
703-
DiagnosticInfoUnsupported BadTag(Fn, Str.str(), MI.getDebugLoc(), DS_Warning);
704-
Fn.getContext().diagnose(BadTag);
703+
Fn.getContext().diagnose(
704+
DiagnosticInfoUnsupported(Fn, Str.str(), MI.getDebugLoc(), DS_Warning));
705705
}
706706

707707
/// Reads \p MI's MMRAs to parse the "amdgpu-as" MMRA.
@@ -734,8 +734,8 @@ static SIAtomicAddrSpace getFenceAddrSpaceMMRA(const MachineInstr &MI,
734734
void SIMemOpAccess::reportUnsupported(const MachineBasicBlock::iterator &MI,
735735
const char *Msg) const {
736736
const Function &Func = MI->getParent()->getParent()->getFunction();
737-
DiagnosticInfoUnsupported Diag(Func, Msg, MI->getDebugLoc());
738-
Func.getContext().diagnose(Diag);
737+
Func.getContext().diagnose(
738+
DiagnosticInfoUnsupported(Func, Msg, MI->getDebugLoc()));
739739
}
740740

741741
std::optional<std::tuple<SIAtomicScope, SIAtomicAddrSpace, bool>>

0 commit comments

Comments
 (0)