[llvm] [LowerSwitch] Implement verifyAnalysis (PR #68294)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 07:33:18 PDT 2023


================
@@ -569,8 +569,17 @@ class LowerSwitchLegacyPass : public FunctionPass {
     initializeLowerSwitchLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
+  // Remember the current function. Only used for verification.
+  Function *F;
+
   bool runOnFunction(Function &F) override;
 
+  void verifyAnalysis() const override {
+    for (auto &BB : *F)
+      assert(!isa<SwitchInst>(BB.getTerminator()) &&
----------------
arsenm wrote:

Is verifyAnalysis supposed to work in a release build? I think you're in danger of the unused member variable as is

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


More information about the llvm-commits mailing list