[llvm] e9e4fc0 - BPF: fix a bug in IRPeephole pass

Yonghong Song via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 18 10:18:59 PDT 2021


Author: Yonghong Song
Date: 2021-10-18T10:18:24-07:00
New Revision: e9e4fc0fd3e0780207c731a1f2b8f6aacd24e8f8

URL: https://github.com/llvm/llvm-project/commit/e9e4fc0fd3e0780207c731a1f2b8f6aacd24e8f8
DIFF: https://github.com/llvm/llvm-project/commit/e9e4fc0fd3e0780207c731a1f2b8f6aacd24e8f8.diff

LOG: BPF: fix a bug in IRPeephole pass

Commit 009f3a89d833 ("BPF: remove intrindics @llvm.stacksave()
and @llvm.stackrestore()") implemented IRPeephole pass to remove
llvm.stacksave()/stackrestore() instrinsics.
Buildbot reported a failure:
  UNREACHABLE executed at ../lib/IR/LegacyPassManager.cpp:1445!
which is:
  llvm_unreachable("Pass modifies its input and doesn't report it");

The code has changed but the implementation didn't return true
for changing. This patch fixed this problem.

Added: 
    

Modified: 
    llvm/lib/Target/BPF/BPFIRPeephole.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/BPF/BPFIRPeephole.cpp b/llvm/lib/Target/BPF/BPFIRPeephole.cpp
index 9192205105e33..d6a70012dca04 100644
--- a/llvm/lib/Target/BPF/BPFIRPeephole.cpp
+++ b/llvm/lib/Target/BPF/BPFIRPeephole.cpp
@@ -30,6 +30,7 @@ namespace {
 static bool BPFIRPeepholeImpl(Function &F) {
   LLVM_DEBUG(dbgs() << "******** BPF IR Peephole ********\n");
 
+  bool Changed = false;
   Instruction *ToErase = nullptr;
   for (auto &BB : F) {
     for (auto &I : BB) {
@@ -64,6 +65,7 @@ static bool BPFIRPeepholeImpl(Function &F) {
           auto *Inst = cast<Instruction>(*Call->user_begin());
           LLVM_DEBUG(dbgs() << "Remove:"; I.dump());
           LLVM_DEBUG(dbgs() << "Remove:"; Inst->dump(); dbgs() << '\n');
+          Changed = true;
           Inst->eraseFromParent();
           ToErase = &I;
         }
@@ -83,13 +85,14 @@ static bool BPFIRPeepholeImpl(Function &F) {
           continue;
         LLVM_DEBUG(dbgs() << "Remove:"; I.dump());
         LLVM_DEBUG(dbgs() << "Remove:"; Call->dump(); dbgs() << '\n');
+        Changed = true;
         Call->eraseFromParent();
         ToErase = &I;
       }
     }
   }
 
-  return false;
+  return Changed;
 }
 
 class BPFIRPeephole final : public FunctionPass {


        


More information about the llvm-commits mailing list