[PATCH] D156497: [BPF] report fatal error rather than miscompile
Tamir Duberstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 27 17:32:13 PDT 2023
tamird updated this revision to Diff 544985.
tamird added a comment.
Add missing delegation.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156497/new/
https://reviews.llvm.org/D156497
Files:
llvm/lib/Target/BPF/BPFISelLowering.cpp
llvm/lib/Target/BPF/BPFISelLowering.h
Index: llvm/lib/Target/BPF/BPFISelLowering.h
===================================================================
--- llvm/lib/Target/BPF/BPFISelLowering.h
+++ llvm/lib/Target/BPF/BPFISelLowering.h
@@ -66,6 +66,8 @@
MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override;
+ void finalizeLowering(MachineFunction &MF) const override;
+
private:
// Control Instruction Selection Features
bool HasAlu32;
@@ -73,6 +75,11 @@
bool HasJmpExt;
bool HasMovsx;
+ mutable bool HasError = false;
+
+ void fail(const SDLoc &DL, SelectionDAG &DAG, const Twine &Msg,
+ SDValue Val) const;
+
SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
Index: llvm/lib/Target/BPF/BPFISelLowering.cpp
===================================================================
--- llvm/lib/Target/BPF/BPFISelLowering.cpp
+++ llvm/lib/Target/BPF/BPFISelLowering.cpp
@@ -35,22 +35,18 @@
cl::Hidden, cl::init(false),
cl::desc("Expand memcpy into load/store pairs in order"));
-static void fail(const SDLoc &DL, SelectionDAG &DAG, const Twine &Msg) {
- MachineFunction &MF = DAG.getMachineFunction();
- DAG.getContext()->diagnose(
- DiagnosticInfoUnsupported(MF.getFunction(), Msg, DL.getDebugLoc()));
-}
-
-static void fail(const SDLoc &DL, SelectionDAG &DAG, const char *Msg,
- SDValue Val) {
- MachineFunction &MF = DAG.getMachineFunction();
+void BPFTargetLowering::fail(const SDLoc &DL, SelectionDAG &DAG,
+ const Twine &Msg, SDValue Val = {}) const {
+ HasError = true;
std::string Str;
- raw_string_ostream OS(Str);
- OS << Msg;
- Val->print(OS);
- OS.flush();
- DAG.getContext()->diagnose(
- DiagnosticInfoUnsupported(MF.getFunction(), Str, DL.getDebugLoc()));
+ if (Val) {
+ raw_string_ostream OS(Str);
+ Val->print(OS);
+ OS << ' ';
+ }
+ MachineFunction &MF = DAG.getMachineFunction();
+ DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
+ MF.getFunction(), Msg.concat(Str), DL.getDebugLoc()));
}
BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM,
@@ -871,6 +867,13 @@
return (getHasAlu32() && VT == MVT::i32) ? MVT::i32 : MVT::i64;
}
+void BPFTargetLowering::finalizeLowering(MachineFunction &MF) const {
+ if (HasError) {
+ report_fatal_error("failed to generate BPF instructions, see diagnostics");
+ }
+ TargetLowering::finalizeLowering(MF);
+}
+
bool BPFTargetLowering::isLegalAddressingMode(const DataLayout &DL,
const AddrMode &AM, Type *Ty,
unsigned AS,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156497.544985.patch
Type: text/x-patch
Size: 2740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230728/379aebd5/attachment.bin>
More information about the llvm-commits
mailing list