Skip to content

Commit

Permalink
fix the way passes are defined as in PR #523
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafaelhoushi committed Dec 21, 2021
1 parent ada2de5 commit 2d574ff
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions examples/loop_optimizations_service/opt_loops/opt_loops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

using namespace llvm;

namespace llvm {
namespace {
/// Input LLVM module file name.
cl::opt<std::string> InputFilename(cl::Positional, cl::desc("Specify input filename"),
cl::value_desc("filename"), cl::init("-"));
Expand Down Expand Up @@ -80,9 +80,6 @@ static cl::opt<bool> PreserveAssemblyUseListOrder(
static cl::opt<bool> DebugifyEach(
"debugify-each", cl::desc("Start each pass with debugify and end it with check-debugify"));

// The INITIALIZE_PASS_XXX macros put the initialiser in the llvm namespace.
void initializeLoopCounterPass(PassRegistry& Registry);

class OptCustomPassManager : public legacy::PassManager {
DebugifyStatsMap DIStatsMap;

Expand Down Expand Up @@ -147,14 +144,7 @@ class LoopCounter : public llvm::FunctionPass {
}
};

// Initialise the pass. We have to declare the dependencies we use.
char LoopCounter::ID = 0;
INITIALIZE_PASS_BEGIN(LoopCounter, "count-loops", "Count loops", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_END(LoopCounter, "count-loops", "Count loops", false, false)

// The INITIALIZE_PASS_XXX macros put the initialiser in the llvm namespace.
void initializeLoopConfiguratorPassPass(PassRegistry& Registry);

class LoopConfiguratorPass : public llvm::FunctionPass {
public:
Expand Down Expand Up @@ -186,13 +176,7 @@ class LoopConfiguratorPass : public llvm::FunctionPass {
}
};

// Initialise the pass. We have to declare the dependencies we use.
char LoopConfiguratorPass::ID = 1;
INITIALIZE_PASS_BEGIN(LoopConfiguratorPass, "unroll-loops-configurator",
"Configurates loop unrolling", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_END(LoopConfiguratorPass, "unroll-loops-configurator",
"Configurates loop unrolling", false, false)

/// Reads a module from a file.
/// On error, messages are written to stderr and null is returned.
Expand All @@ -209,8 +193,25 @@ static std::unique_ptr<Module> readModule(LLVMContext& Context, StringRef Name)
return Module;
}

} // namespace

namespace llvm {
// The INITIALIZE_PASS_XXX macros put the initialiser in the llvm namespace.
void initializeLoopCounterPass(PassRegistry& Registry);
void initializeLoopConfiguratorPassPass(PassRegistry& Registry);
} // namespace llvm

// Initialise the pass. We have to declare the dependencies we use.
INITIALIZE_PASS_BEGIN(LoopCounter, "count-loops", "Count loops", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_END(LoopCounter, "count-loops", "Count loops", false, false)

INITIALIZE_PASS_BEGIN(LoopConfiguratorPass, "unroll-loops-configurator",
"Configurates loop unrolling", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_END(LoopConfiguratorPass, "unroll-loops-configurator",
"Configurates loop unrolling", false, false)

int main(int argc, char** argv) {
cl::ParseCommandLineOptions(argc, argv,
" LLVM-Counter\n\n"
Expand Down

0 comments on commit 2d574ff

Please sign in to comment.