[llvm] [BPF] Remove 'may_goto 0' instructions (PR #123482)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 14:52:04 PST 2025


================
@@ -682,6 +685,65 @@ bool BPFMIPreEmitPeephole::insertMissingCallerSavedSpills() {
   return Changed;
 }
 
+bool BPFMIPreEmitPeephole::removeMayGotoZero() {
+  bool Changed = false;
+  MachineBasicBlock *Prev_MBB, *Curr_MBB = nullptr;
+  MachineBasicBlock *ToErase = nullptr;
+
+  for (MachineBasicBlock &MBB : reverse(*MF)) {
+    if (ToErase) {
----------------
eddyz87 wrote:

Note: there is a utility function `llvm::make_early_inc_range`, I think it could be used here to avoid the `ToErase` variable.

https://github.com/llvm/llvm-project/pull/123482


More information about the llvm-commits mailing list