1717#include " llvm/ADT/STLExtras.h"
1818#include " llvm/ADT/SmallPtrSet.h"
1919#include " llvm/ADT/SmallVector.h"
20- #include " llvm/Analysis/AssumptionCache.h"
21- #include " llvm/Analysis/LazyValueInfo.h"
2220#include " llvm/Analysis/ValueTracking.h"
2321#include " llvm/IR/BasicBlock.h"
2422#include " llvm/IR/CFG.h"
@@ -534,6 +532,25 @@ void ProcessSwitchInst(SwitchInst *SI,
534532 DeleteList.insert (OldDefault);
535533}
536534
535+ // / Replace all SwitchInst instructions with chained branch instructions.
536+ class LowerSwitchLegacyPass : public FunctionPass {
537+ public:
538+ // Pass identification, replacement for typeid
539+ static char ID;
540+
541+ LowerSwitchLegacyPass () : FunctionPass(ID) {
542+ initializeLowerSwitchLegacyPassPass (*PassRegistry::getPassRegistry ());
543+ }
544+
545+ bool runOnFunction (Function &F) override ;
546+
547+ void getAnalysisUsage (AnalysisUsage &AU) const override {
548+ AU.addRequired <LazyValueInfoWrapperPass>();
549+ }
550+ };
551+
552+ } // end anonymous namespace
553+ namespace llvm {
537554bool LowerSwitch (Function &F, LazyValueInfo *LVI, AssumptionCache *AC) {
538555 bool Changed = false ;
539556 SmallPtrSet<BasicBlock *, 8 > DeleteList;
@@ -558,26 +575,7 @@ bool LowerSwitch(Function &F, LazyValueInfo *LVI, AssumptionCache *AC) {
558575
559576 return Changed;
560577}
561-
562- // / Replace all SwitchInst instructions with chained branch instructions.
563- class LowerSwitchLegacyPass : public FunctionPass {
564- public:
565- // Pass identification, replacement for typeid
566- static char ID;
567-
568- LowerSwitchLegacyPass () : FunctionPass(ID) {
569- initializeLowerSwitchLegacyPassPass (*PassRegistry::getPassRegistry ());
570- }
571-
572- bool runOnFunction (Function &F) override ;
573-
574- void getAnalysisUsage (AnalysisUsage &AU) const override {
575- AU.addRequired <LazyValueInfoWrapperPass>();
576- }
577- };
578-
579- } // end anonymous namespace
580-
578+ } // namespace llvm
581579char LowerSwitchLegacyPass::ID = 0 ;
582580
583581// Publicly exposed interface to pass...
0 commit comments