Skip to content

Commit 7c6ca18

Browse files
committed
[globalisel] Allow backends to report an issue without triggering fallback. NFC
Summary: This will allow us to fix the issue where the lost locations verifier causes CodeGen changes on lost locations because it falls back on DAGISel Reviewers: qcolombet, bogner, aprantl, vsk, paquette Subscribers: rovka, hiraditya, volkan, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78261
1 parent bf60953 commit 7c6ca18

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

llvm/include/llvm/CodeGen/GlobalISel/Utils.h

+6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ void reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
115115
const char *PassName, StringRef Msg,
116116
const MachineInstr &MI);
117117

118+
/// Report an ISel warning as a missed optimization remark to the LLVMContext's
119+
/// diagnostic stream.
120+
void reportGISelWarning(MachineFunction &MF, const TargetPassConfig &TPC,
121+
MachineOptimizationRemarkEmitter &MORE,
122+
MachineOptimizationRemarkMissed &R);
123+
118124
/// If \p VReg is defined by a G_CONSTANT fits in int64_t
119125
/// returns it.
120126
Optional<int64_t> getConstantVRegVal(Register VReg,

llvm/lib/CodeGen/GlobalISel/Utils.cpp

+22-7
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,37 @@ bool llvm::isTriviallyDead(const MachineInstr &MI,
198198
return true;
199199
}
200200

201-
void llvm::reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
202-
MachineOptimizationRemarkEmitter &MORE,
203-
MachineOptimizationRemarkMissed &R) {
204-
MF.getProperties().set(MachineFunctionProperties::Property::FailedISel);
205-
201+
static void reportGISelDiagnostic(DiagnosticSeverity Severity,
202+
MachineFunction &MF,
203+
const TargetPassConfig &TPC,
204+
MachineOptimizationRemarkEmitter &MORE,
205+
MachineOptimizationRemarkMissed &R) {
206+
bool IsFatal = Severity == DS_Error &&
207+
TPC.isGlobalISelAbortEnabled();
206208
// Print the function name explicitly if we don't have a debug location (which
207209
// makes the diagnostic less useful) or if we're going to emit a raw error.
208-
if (!R.getLocation().isValid() || TPC.isGlobalISelAbortEnabled())
210+
if (!R.getLocation().isValid() || IsFatal)
209211
R << (" (in function: " + MF.getName() + ")").str();
210212

211-
if (TPC.isGlobalISelAbortEnabled())
213+
if (IsFatal)
212214
report_fatal_error(R.getMsg());
213215
else
214216
MORE.emit(R);
215217
}
216218

219+
void llvm::reportGISelWarning(MachineFunction &MF, const TargetPassConfig &TPC,
220+
MachineOptimizationRemarkEmitter &MORE,
221+
MachineOptimizationRemarkMissed &R) {
222+
reportGISelDiagnostic(DS_Warning, MF, TPC, MORE, R);
223+
}
224+
225+
void llvm::reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
226+
MachineOptimizationRemarkEmitter &MORE,
227+
MachineOptimizationRemarkMissed &R) {
228+
MF.getProperties().set(MachineFunctionProperties::Property::FailedISel);
229+
reportGISelDiagnostic(DS_Error, MF, TPC, MORE, R);
230+
}
231+
217232
void llvm::reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
218233
MachineOptimizationRemarkEmitter &MORE,
219234
const char *PassName, StringRef Msg,

0 commit comments

Comments
 (0)