[llvm] [BPF] Handle unreachable with a kfunc call (PR #131731)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 21 22:55:32 PDT 2025
================
@@ -320,6 +320,7 @@ struct BPFMIPreEmitPeephole : public MachineFunctionPass {
bool adjustBranch();
bool insertMissingCallerSavedSpills();
bool removeMayGotoZero();
+ bool addExitAfterUnreachable();
----------------
eddyz87 wrote:
Unexpectedly, generating `exit` at selection DAG level is a head scratcher. The following seems to work:
```cpp
@@ -759,7 +774,10 @@ SDValue BPFTargetLowering::LowerTRAP(SDValue Op, SelectionDAG &DAG) const {
CLI.DL = DL;
CLI.NoMerge = false;
CLI.DoesNotReturn = true;
- return LowerCall(CLI, InVals);
+ SDValue Chain = LowerCall(CLI, InVals);
+ SDValue Glue = Chain.getValue(1);
+ return DAG.getNode(BPFISD::RET_GLUE, DL, MVT::Other,
+ SmallVector<SDValue>{Chain, Glue});
}
```
Relies on `BPFretglue` translation to `exit` as described in `BPFInstrInfo.td`.
https://github.com/llvm/llvm-project/pull/131731
More information about the llvm-commits
mailing list