BarrierNoopPass.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //===- BarrierNoopPass.cpp - A barrier pass for the pass manager ----------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // NOTE: DO NOT USE THIS IF AVOIDABLE
  10. //
  11. // This pass is a nonce pass intended to allow manipulation of the implicitly
  12. // nesting pass manager. For example, it can be used to cause a CGSCC pass
  13. // manager to be closed prior to running a new collection of function passes.
  14. //
  15. // FIXME: This is a huge HACK. This should be removed when the pass manager's
  16. // nesting is made explicit instead of implicit.
  17. //
  18. //===----------------------------------------------------------------------===//
  19. #include "llvm/InitializePasses.h"
  20. #include "llvm/Pass.h"
  21. #include "llvm/Transforms/IPO.h"
  22. using namespace llvm;
  23. namespace {
  24. /// A nonce module pass used to place a barrier in a pass manager.
  25. ///
  26. /// There is no mechanism for ending a CGSCC pass manager once one is started.
  27. /// This prevents extension points from having clear deterministic ordering
  28. /// when they are phrased as non-module passes.
  29. class BarrierNoop : public ModulePass {
  30. public:
  31. static char ID; // Pass identification.
  32. BarrierNoop() : ModulePass(ID) {
  33. initializeBarrierNoopPass(*PassRegistry::getPassRegistry());
  34. }
  35. bool runOnModule(Module &M) override { return false; }
  36. };
  37. }
  38. ModulePass *llvm::createBarrierNoopPass() { return new BarrierNoop(); }
  39. char BarrierNoop::ID = 0;
  40. INITIALIZE_PASS(BarrierNoop, "barrier", "A No-Op Barrier Pass",
  41. false, false)