BarrierNoopPass.cpp revision 360784
1192661Ssam//===- BarrierNoopPass.cpp - A barrier pass for the pass manager ----------===//
2192661Ssam//
3192661Ssam// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4192661Ssam// See https://llvm.org/LICENSE.txt for license information.
5192661Ssam// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6192661Ssam//
7192661Ssam//===----------------------------------------------------------------------===//
8192661Ssam//
9192661Ssam// NOTE: DO NOT USE THIS IF AVOIDABLE
10192661Ssam//
11192661Ssam// This pass is a nonce pass intended to allow manipulation of the implicitly
12192661Ssam// nesting pass manager. For example, it can be used to cause a CGSCC pass
13192661Ssam// manager to be closed prior to running a new collection of function passes.
14192661Ssam//
15192661Ssam// FIXME: This is a huge HACK. This should be removed when the pass manager's
16192661Ssam// nesting is made explicit instead of implicit.
17192661Ssam//
18192661Ssam//===----------------------------------------------------------------------===//
19192661Ssam
20192661Ssam#include "llvm/InitializePasses.h"
21192661Ssam#include "llvm/Pass.h"
22192661Ssam#include "llvm/Transforms/IPO.h"
23192661Ssamusing namespace llvm;
24192661Ssam
25192661Ssamnamespace {
26192661Ssam/// A nonce module pass used to place a barrier in a pass manager.
27192661Ssam///
28192661Ssam/// There is no mechanism for ending a CGSCC pass manager once one is started.
29192661Ssam/// This prevents extension points from having clear deterministic ordering
30192661Ssam/// when they are phrased as non-module passes.
31192661Ssamclass BarrierNoop : public ModulePass {
32192661Ssampublic:
33192661Ssam  static char ID; // Pass identification.
34192661Ssam
35192661Ssam  BarrierNoop() : ModulePass(ID) {
36192661Ssam    initializeBarrierNoopPass(*PassRegistry::getPassRegistry());
37192661Ssam  }
38192661Ssam
39192661Ssam  bool runOnModule(Module &M) override { return false; }
40192661Ssam};
41192661Ssam}
42192661Ssam
43192661SsamModulePass *llvm::createBarrierNoopPass() { return new BarrierNoop(); }
44192661Ssam
45192661Ssamchar BarrierNoop::ID = 0;
46192661SsamINITIALIZE_PASS(BarrierNoop, "barrier", "A No-Op Barrier Pass",
47192661Ssam                false, false)
48192661Ssam