Skip to content

Commit b7bb256

Browse files
authored
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.
1 parent e653dc9 commit b7bb256

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
@@ -739,7 +739,8 @@ namespace {
739739
class LTODiagnosticInfo : public DiagnosticInfo {
740740
const Twine &Msg;
741741
public:
742-
LTODiagnosticInfo(const Twine &DiagMsg, DiagnosticSeverity Severity=DS_Error)
742+
LTODiagnosticInfo(const Twine &DiagMsg LLVM_LIFETIME_BOUND,
743+
DiagnosticSeverity Severity = DS_Error)
743744
: DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
744745
void print(DiagnosticPrinter &DP) const override { DP << Msg; }
745746
};

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ namespace {
163163
class ThinLTODiagnosticInfo : public DiagnosticInfo {
164164
const Twine &Msg;
165165
public:
166-
ThinLTODiagnosticInfo(const Twine &DiagMsg,
166+
ThinLTODiagnosticInfo(const Twine &DiagMsg LLVM_LIFETIME_BOUND,
167167
DiagnosticSeverity Severity = DS_Error)
168168
: DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
169169
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
@@ -1389,9 +1389,8 @@ SDValue AMDGPUTargetLowering::lowerUnhandledCall(CallLoweringInfo &CLI,
13891389
else if (const GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
13901390
FuncName = G->getGlobal()->getName();
13911391

1392-
DiagnosticInfoUnsupported NoCalls(
1393-
Fn, Reason + FuncName, CLI.DL.getDebugLoc());
1394-
DAG.getContext()->diagnose(NoCalls);
1392+
DAG.getContext()->diagnose(
1393+
DiagnosticInfoUnsupported(Fn, Reason + FuncName, CLI.DL.getDebugLoc()));
13951394

13961395
if (!CLI.IsTailCall) {
13971396
for (ISD::InputArg &Arg : CLI.Ins)
@@ -1410,9 +1409,8 @@ SDValue AMDGPUTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
14101409
SelectionDAG &DAG) const {
14111410
const Function &Fn = DAG.getMachineFunction().getFunction();
14121411

1413-
DiagnosticInfoUnsupported NoDynamicAlloca(Fn, "unsupported dynamic alloca",
1414-
SDLoc(Op).getDebugLoc());
1415-
DAG.getContext()->diagnose(NoDynamicAlloca);
1412+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
1413+
Fn, "unsupported dynamic alloca", SDLoc(Op).getDebugLoc()));
14161414
auto Ops = {DAG.getConstant(0, SDLoc(), Op.getValueType()), Op.getOperand(0)};
14171415
return DAG.getMergeValues(Ops, SDLoc());
14181416
}
@@ -1527,10 +1525,9 @@ SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI,
15271525
!AMDGPU::isNamedBarrier(*cast<GlobalVariable>(GV))) {
15281526
SDLoc DL(Op);
15291527
const Function &Fn = DAG.getMachineFunction().getFunction();
1530-
DiagnosticInfoUnsupported BadLDSDecl(
1531-
Fn, "local memory global used by non-kernel function",
1532-
DL.getDebugLoc(), DS_Warning);
1533-
DAG.getContext()->diagnose(BadLDSDecl);
1528+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
1529+
Fn, "local memory global used by non-kernel function",
1530+
DL.getDebugLoc(), DS_Warning));
15341531

15351532
// We currently don't have a way to correctly allocate LDS objects that
15361533
// 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
@@ -2339,9 +2339,9 @@ bool AMDGPUInstructionSelector::selectG_INTRINSIC_W_SIDE_EFFECTS(
23392339
case Intrinsic::amdgcn_exp_compr:
23402340
if (!STI.hasCompressedExport()) {
23412341
Function &F = I.getMF()->getFunction();
2342-
DiagnosticInfoUnsupported NoFpRet(
2343-
F, "intrinsic not supported on subtarget", I.getDebugLoc(), DS_Error);
2344-
F.getContext().diagnose(NoFpRet);
2342+
F.getContext().diagnose(
2343+
DiagnosticInfoUnsupported(F, "intrinsic not supported on subtarget",
2344+
I.getDebugLoc(), DS_Error));
23452345
return false;
23462346
}
23472347
break;

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,10 +3014,9 @@ bool AMDGPULegalizerInfo::legalizeGlobalValue(
30143014
GV->getName() != "llvm.amdgcn.module.lds" &&
30153015
!AMDGPU::isNamedBarrier(*cast<GlobalVariable>(GV))) {
30163016
const Function &Fn = MF.getFunction();
3017-
DiagnosticInfoUnsupported BadLDSDecl(
3018-
Fn, "local memory global used by non-kernel function", MI.getDebugLoc(),
3019-
DS_Warning);
3020-
Fn.getContext().diagnose(BadLDSDecl);
3017+
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
3018+
Fn, "local memory global used by non-kernel function",
3019+
MI.getDebugLoc(), DS_Warning));
30213020

30223021
// We currently don't have a way to correctly allocate LDS objects that
30233022
// aren't directly associated with a kernel. We do force inlining of
@@ -7046,11 +7045,9 @@ bool AMDGPULegalizerInfo::legalizeDebugTrap(MachineInstr &MI,
70467045
// accordingly
70477046
if (!ST.isTrapHandlerEnabled() ||
70487047
ST.getTrapHandlerAbi() != GCNSubtarget::TrapHandlerAbi::AMDHSA) {
7049-
DiagnosticInfoUnsupported NoTrap(B.getMF().getFunction(),
7050-
"debugtrap handler not supported",
7051-
MI.getDebugLoc(), DS_Warning);
7052-
LLVMContext &Ctx = B.getMF().getFunction().getContext();
7053-
Ctx.diagnose(NoTrap);
7048+
Function &Fn = B.getMF().getFunction();
7049+
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
7050+
Fn, "debugtrap handler not supported", MI.getDebugLoc(), DS_Warning));
70547051
} else {
70557052
// Insert debug-trap instruction
70567053
B.buildInstr(AMDGPU::S_TRAP)
@@ -7078,10 +7075,9 @@ bool AMDGPULegalizerInfo::legalizeBVHIntersectRayIntrinsic(
70787075
Register TDescr = MI.getOperand(7).getReg();
70797076

70807077
if (!ST.hasGFX10_AEncoding()) {
7081-
DiagnosticInfoUnsupported BadIntrin(B.getMF().getFunction(),
7082-
"intrinsic not supported on subtarget",
7083-
MI.getDebugLoc());
7084-
B.getMF().getFunction().getContext().diagnose(BadIntrin);
7078+
Function &Fn = B.getMF().getFunction();
7079+
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
7080+
Fn, "intrinsic not supported on subtarget", MI.getDebugLoc()));
70857081
return false;
70867082
}
70877083

@@ -7231,10 +7227,9 @@ bool AMDGPULegalizerInfo::legalizeBVHDualOrBVH8IntersectRayIntrinsic(
72317227
Register TDescr = MI.getOperand(10).getReg();
72327228

72337229
if (!ST.hasBVHDualAndBVH8Insts()) {
7234-
DiagnosticInfoUnsupported BadIntrin(B.getMF().getFunction(),
7235-
"intrinsic not supported on subtarget",
7236-
MI.getDebugLoc());
7237-
B.getMF().getFunction().getContext().diagnose(BadIntrin);
7230+
Function &Fn = B.getMF().getFunction();
7231+
Fn.getContext().diagnose(DiagnosticInfoUnsupported(
7232+
Fn, "intrinsic not supported on subtarget", MI.getDebugLoc()));
72387233
return false;
72397234
}
72407235

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
@@ -2860,9 +2860,8 @@ SDValue SITargetLowering::LowerFormalArguments(
28602860
bool IsError = false;
28612861

28622862
if (Subtarget->isAmdHsaOS() && AMDGPU::isGraphics(CallConv)) {
2863-
DiagnosticInfoUnsupported NoGraphicsHSA(
2864-
Fn, "unsupported non-compute shaders with HSA", DL.getDebugLoc());
2865-
DAG.getContext()->diagnose(NoGraphicsHSA);
2863+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
2864+
Fn, "unsupported non-compute shaders with HSA", DL.getDebugLoc()));
28662865
IsError = true;
28672866
}
28682867

@@ -3086,11 +3085,10 @@ SDValue SITargetLowering::LowerFormalArguments(
30863085
if (Arg.isOrigArg()) {
30873086
Argument *OrigArg = Fn.getArg(Arg.getOrigArgIndex());
30883087
if (OrigArg->hasAttribute("amdgpu-hidden-argument")) {
3089-
DiagnosticInfoUnsupported NonPreloadHiddenArg(
3088+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
30903089
*OrigArg->getParent(),
30913090
"hidden argument in kernel signature was not preloaded",
3092-
DL.getDebugLoc());
3093-
DAG.getContext()->diagnose(NonPreloadHiddenArg);
3091+
DL.getDebugLoc()));
30943092
}
30953093
}
30963094

@@ -7315,11 +7313,10 @@ SDValue SITargetLowering::lowerDEBUGTRAP(SDValue Op, SelectionDAG &DAG) const {
73157313

73167314
if (!Subtarget->isTrapHandlerEnabled() ||
73177315
Subtarget->getTrapHandlerAbi() != GCNSubtarget::TrapHandlerAbi::AMDHSA) {
7318-
DiagnosticInfoUnsupported NoTrap(MF.getFunction(),
7319-
"debugtrap handler not supported",
7320-
Op.getDebugLoc(), DS_Warning);
73217316
LLVMContext &Ctx = MF.getFunction().getContext();
7322-
Ctx.diagnose(NoTrap);
7317+
Ctx.diagnose(DiagnosticInfoUnsupported(MF.getFunction(),
7318+
"debugtrap handler not supported",
7319+
Op.getDebugLoc(), DS_Warning));
73237320
return Chain;
73247321
}
73257322

@@ -8092,19 +8089,17 @@ SDValue SITargetLowering::lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op,
80928089

80938090
static SDValue emitNonHSAIntrinsicError(SelectionDAG &DAG, const SDLoc &DL,
80948091
EVT VT) {
8095-
DiagnosticInfoUnsupported BadIntrin(DAG.getMachineFunction().getFunction(),
8096-
"non-hsa intrinsic with hsa target",
8097-
DL.getDebugLoc());
8098-
DAG.getContext()->diagnose(BadIntrin);
8092+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
8093+
DAG.getMachineFunction().getFunction(),
8094+
"non-hsa intrinsic with hsa target", DL.getDebugLoc()));
80998095
return DAG.getPOISON(VT);
81008096
}
81018097

81028098
static SDValue emitRemovedIntrinsicError(SelectionDAG &DAG, const SDLoc &DL,
81038099
EVT VT) {
8104-
DiagnosticInfoUnsupported BadIntrin(DAG.getMachineFunction().getFunction(),
8105-
"intrinsic not supported on subtarget",
8106-
DL.getDebugLoc());
8107-
DAG.getContext()->diagnose(BadIntrin);
8100+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
8101+
DAG.getMachineFunction().getFunction(),
8102+
"intrinsic not supported on subtarget", DL.getDebugLoc()));
81088103
return DAG.getPOISON(VT);
81098104
}
81108105

@@ -8813,10 +8808,9 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
88138808
case Intrinsic::amdgcn_dispatch_ptr:
88148809
case Intrinsic::amdgcn_queue_ptr: {
88158810
if (!Subtarget->isAmdHsaOrMesa(MF.getFunction())) {
8816-
DiagnosticInfoUnsupported BadIntrin(
8811+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
88178812
MF.getFunction(), "unsupported hsa intrinsic without hsa target",
8818-
DL.getDebugLoc());
8819-
DAG.getContext()->diagnose(BadIntrin);
8813+
DL.getDebugLoc()));
88208814
return DAG.getPOISON(VT);
88218815
}
88228816

@@ -9925,10 +9919,9 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
99259919
switch (IntrinsicID) {
99269920
case Intrinsic::amdgcn_exp_compr: {
99279921
if (!Subtarget->hasCompressedExport()) {
9928-
DiagnosticInfoUnsupported BadIntrin(
9922+
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
99299923
DAG.getMachineFunction().getFunction(),
9930-
"intrinsic not supported on subtarget", DL.getDebugLoc());
9931-
DAG.getContext()->diagnose(BadIntrin);
9924+
"intrinsic not supported on subtarget", DL.getDebugLoc()));
99329925
}
99339926
SDValue Src0 = Op.getOperand(4);
99349927
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)