10b57cec5SDimitry Andric //===- BarrierNoopPass.cpp - A barrier pass for the pass manager ----------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // NOTE: DO NOT USE THIS IF AVOIDABLE 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric // This pass is a nonce pass intended to allow manipulation of the implicitly 120b57cec5SDimitry Andric // nesting pass manager. For example, it can be used to cause a CGSCC pass 130b57cec5SDimitry Andric // manager to be closed prior to running a new collection of function passes. 140b57cec5SDimitry Andric // 150b57cec5SDimitry Andric // FIXME: This is a huge HACK. This should be removed when the pass manager's 160b57cec5SDimitry Andric // nesting is made explicit instead of implicit. 170b57cec5SDimitry Andric // 180b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 190b57cec5SDimitry Andric 20*480093f4SDimitry Andric #include "llvm/InitializePasses.h" 210b57cec5SDimitry Andric #include "llvm/Pass.h" 220b57cec5SDimitry Andric #include "llvm/Transforms/IPO.h" 230b57cec5SDimitry Andric using namespace llvm; 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric namespace { 260b57cec5SDimitry Andric /// A nonce module pass used to place a barrier in a pass manager. 270b57cec5SDimitry Andric /// 280b57cec5SDimitry Andric /// There is no mechanism for ending a CGSCC pass manager once one is started. 290b57cec5SDimitry Andric /// This prevents extension points from having clear deterministic ordering 300b57cec5SDimitry Andric /// when they are phrased as non-module passes. 310b57cec5SDimitry Andric class BarrierNoop : public ModulePass { 320b57cec5SDimitry Andric public: 330b57cec5SDimitry Andric static char ID; // Pass identification. 340b57cec5SDimitry Andric BarrierNoop()350b57cec5SDimitry Andric BarrierNoop() : ModulePass(ID) { 360b57cec5SDimitry Andric initializeBarrierNoopPass(*PassRegistry::getPassRegistry()); 370b57cec5SDimitry Andric } 380b57cec5SDimitry Andric runOnModule(Module & M)390b57cec5SDimitry Andric bool runOnModule(Module &M) override { return false; } 400b57cec5SDimitry Andric }; 410b57cec5SDimitry Andric } 420b57cec5SDimitry Andric createBarrierNoopPass()430b57cec5SDimitry AndricModulePass *llvm::createBarrierNoopPass() { return new BarrierNoop(); } 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric char BarrierNoop::ID = 0; 460b57cec5SDimitry Andric INITIALIZE_PASS(BarrierNoop, "barrier", "A No-Op Barrier Pass", 470b57cec5SDimitry Andric false, false) 48